Go driver
This section describes Fauna’s open source Go driver, which provides the resources required to interact with FaunaDB.
Supported Go versions
Currently, the driver is tested on the following Go versions:
-
1.5
-
1.6
-
1.7
-
1.8
-
1.9
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.Class("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
-
For more information about FaunaDB query language, consult our query language reference documentation.
-
Driver-specific reference documentation is hosted at GoDoc.
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!