Skip to content

Instantly share code, notes, and snippets.

@hiranya911
Created March 11, 2018 19:38
Show Gist options
  • Save hiranya911/f601b951168c445932443b470f8976f0 to your computer and use it in GitHub Desktop.
Save hiranya911/f601b951168c445932443b470f8976f0 to your computer and use it in GitHub Desktop.
ctx := context.Background()
config := &firebase.Config{
DatabaseURL: "https://database-name.firebaseio.com",
}
app, err := firebase.NewApp(ctx, config)
if err != nil {
log.Fatal(err)
}
client, err := app.Database(ctx)
if err != nil {
log.Fatal(err)
}
acc := Account{
Name: "Alice",
Balance: 1000,
}
if err := client.NewRef("accounts/alice").Set(ctx, acc); err != nil {
log.Fatal(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment