firebase
A Go package for the Firebase API #golang
Installation
Install the package with go:
go get github.com/melvinmt/firebase
And add it to your go file:
package name
import (
"github.com/melvinmt/firebase"
)
Usage
package main
import (
"github.com/melvinmt/firebase"
"fmt"
)
type PersonName struct {
First string
Last string
}
type Person struct {
Name PersonName
}
func main() {
var err error
url := "https://SampleChat.firebaseIO-demo.com/users/fred/name"
authToken := "MqL0c8tKCtheLSYcygYNtGhU8Z2hULOFs9OKPdEp"
ref := firebase.NewReference(url).Auth(authToken)
personName := PersonName{
First: "Fred",
Last: "Swanson",
}
if err = ref.Write(personName); err != nil {
panic(err)
}
personUrl := "https://SampleChat.firebaseIO-demo.com/users/fred"
personRef := firebase.NewReference(personUrl).Export(false)
fred := Person{}
if err = personRef.Value(fred); err != nil {
panic(err)
}
fmt.Println(fred.Name.First, fred.Name.Last)
}
Docs
http://godoc.org/github.com/melvinmt/firebase