Skip to content

Instantly share code, notes, and snippets.

@nidhi-canopas
Last active October 12, 2022 06:56
Show Gist options
  • Save nidhi-canopas/6ef86f2ad4ee245e93f087a85a00ec59 to your computer and use it in GitHub Desktop.
Save nidhi-canopas/6ef86f2ad4ee245e93f087a85a00ec59 to your computer and use it in GitHub Desktop.
ctx := context.Background()
// configure database URL
conf := &firebase.Config{
DatabaseURL: "https://fir-realtime-db-demo-xxxxx-default-rtdb.asia-southeast1.firebasedatabase.app",
}
// fetch service account key
opt := option.WithCredentialsFile("fir-realtime-db-demo-xxxxx-firebase-adminsdk-2zjoi-9b40ce1e42.json")
app, err := firebase.NewApp(ctx, conf, opt)
if err != nil {
log.Fatalln("error in initializing firebase app: ", err)
}
client, err := app.Database(ctx)
if err != nil {
log.Fatalln("error in creating firebase DB client: ", err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment