Skip to content

Instantly share code, notes, and snippets.

@nidhi-canopas
Last active October 12, 2022 06:57
Show Gist options
  • Save nidhi-canopas/d19682c40eb05740199b837a9ee8c614 to your computer and use it in GitHub Desktop.
Save nidhi-canopas/d19682c40eb05740199b837a9ee8c614 to your computer and use it in GitHub Desktop.
type UserScore struct {
Score int `json:"score"`
}
// get database reference to user score
ref := client.NewRef("user_scores/1")
// read from user_scores using ref
var s UserScore
if err := ref.Get(context.TODO(), &s); err != nil {
log.Fatalln("error in reading from firebase DB: ", err)
}
fmt.Println("retrieved user's score is: ", s.Score)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment