Go driver
This section describes Fauna’s open source Go driver, which provides the resources required to interact with FaunaDB.
Install
To get the latest version run:
go get github.com/fauna/faunadb-go/faunadb
Please note that the driver undergoes breaking changes from time to time. It is recommended to use one of the following methods instead:
Importing
Usage
Here is an example demonstrating how to use the Go driver to execute a simple query on FaunaDB:
package main
import (
"fmt"
f "github.com/fauna/faunadb-go/faunadb"
)
type User struct {
Name string `fauna:"name"`
}
func main() {
client := f.NewFaunaClient("your-secret-here")
res, err := client.Query(f.Get(f.RefClass(f.Collection("user"), "42")))
if err != nil {
panic(err)
}
var user User
if err := res.At(f.ObjKey("data")).Get(&user); err != nil {
panic(err)
}
fmt.Println(user)
}
Next steps
-
Driver repository: https://github.com/fauna/faunadb-go
-
Driver-specific reference documentation is hosted at GoDoc.
-
For more information about the Fauna Query Language, consult our query language reference documentation.
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!