How to Use Firebase from Go

Web
Use the official Firebase Go SDK to initialize a client with your service account credentials and connect to Firestore, Auth, or Storage.

How to Use Firebase from Go

Use the official Firebase Go SDK to initialize a client with your service account credentials and connect to Firestore, Auth, or Storage.

package main

import (
    "context"
    "log"

    "firebase.google.com/go/v4"
    "firebase.google.com/go/v4/storage"
)

func main() {
    ctx := context.Background()
    client, err := firebase.NewApp(ctx, nil, "path/to/serviceAccountKey.json")
    if err != nil {
        log.Fatalf("error initializing app: %v\n", err)
    }
    sClient, err := client.StorageClient(ctx)
    if err != nil {
        log.Fatalf("error initializing storage client: %v\n", err)
    }
    // Use sClient to interact with Firebase Storage
    _ = sClient
}