FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date.

For more details, see the v4 EOL announcement and migration guide. Contact support@fauna.com with any questions.


This section is intended to help Go developers get started using the Fauna Go driver for application development.

Current version and repository location

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/v4/faunadb"

Example application

The following example code runs a bare-bones Go application which creates a new document in a collection called People.


  • A Fauna account. If you don’t have one, see the dashboard quick start for help getting set up.

  • A supported version of Go and the Fauna Go driver. See Installation for driver installation help.


  1. Navigate to the Fauna Dashboard

    Log in to your Fauna account at Fauna Dashboard if you’re not already logged in.

  2. Create a new database

    Click NEW DATABASE and select your Region Group.

  3. Create a new collection

    Click NEW COLLECTION. Name your new collection People and save it.

  4. Create an access key

    Click SECURITY in the left-side navigation menu. Create a new key for your database. Be sure to save the key’s secret in a safe place, as it is only displayed once.

  5. Create a local environment variable with your access key’s secret

    On MacOS and Linux systems, enter the following in a terminal window:

    export FAUNADB_SECRET=<your-secret>

    For Windows systems, enter the following in a terminal window:

    set FAUNADB_SECRET=<your secret>

    For either example, replace <your secret> with the secret for the access key that you created.

  6. Create a local application file

    With your preferred editor, create a file called test.go with the following contents:

    package main
    import (
        f "github.com/fauna/faunadb-go/v4/faunadb"
    var (
    	secret = os.Getenv("FAUNADB_SECRET")
    	endpoint = os.Getenv("FAUNADB_ENDPOINT")
    func main() {
    	if secret == "" {
    		fmt.Println("The FAUNADB_SECRET environment variable is not set, exiting.")
    	if endpoint == "" {
    		endpoint = "https://db.fauna.com/"
    	client := f.NewFaunaClient(secret, f.Endpoint(endpoint))
    	result, err := client.Query(
                    "data": f.Obj{
                        "first": "Linus",
    				    "last": "Torvalds",
    				    "age": 52 }}))
    	if err != nil {
    		fmt.Fprintln(os.Stderr, err)
    	} else {

    The above example app uses the Create function to create a new document in the People collection.

  7. Run your application

    In a terminal window, run the application:

    go run test.go

    You should see results similar to this:

    map[data:map[age:52 first:Linus last:Torvalds] ref:{324878383054848512 0xc000200300 0xc000200300 <nil>} ts:1646087019880000]

    If you get an error, check to make sure your secret is correct.

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!