Go driver

Go logo

This section describes Fauna’s open source Go driver, which provides the resources required to interact with Fauna.

Current stable version



Supported Go versions

Currently, the driver is tested on the following Go versions:

  • 1.11

  • 1.12

  • 1.13

  • 1.14


To get the latest version run:

go get github.com/fauna/faunadb-go/v4/faunadb

Please note that the driver undergoes breaking changes from time to time. It is recommended to use one of the following methods instead:


For better usage, we recommend that you import this driver with an alias import.

Using dep or go get

To import a specific version when using dep or go get, use:

import f "github.com/fauna/faunadb-go/v3/faunadb"


Here is an example demonstrating how to use the Go driver to execute a simple query on Fauna:

package main

import (

    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 {

    var user User

    if err := res.At(f.ObjKey("data")).Get(&user); err != nil {


Query timeout

Your code can configure the client to handle timeouts in two different ways:

  1. by adding a call to QueryTimeoutMS to the options block when instantiating the client, or

  2. by adding a call to TimeoutMS as the second parameter to the .Query method.

When you provide a query timeout, the server waits for the specified period before timing out, if it has yet to complete the current query. Once the period has elapsed, the query fails and the server responds with an error.

Both timeouts are expressed in milliseconds.

For example:

// Specify a query timeout during client instantiation
client := f.NewFaunaClient(
// Specify a query timeout per query
result, err := client.Query(

The value used in the TimeoutMS call passed to .Query() takes precedence over any value used in the QueryTimeoutMS call during client instantiation.

Next steps

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!