Get started

About the official Go driver

Neo4j provides official drivers for a number of popular programming languages. These drivers are supported by Neo4j.

Community drivers also exist for many languages, but vary greatly in terms of feature sets, maturity, and support. To find more about community drivers, visit https://neo4j.com/developer/language-guides/.

The following languages and frameworks are officially supported by Neo4j:

Table 1. Supported languages and frameworks for the 5.x driver series
Language/framework Versions supported

.NET

Go

Java

Java 17.

JavaScript

All LTS versions of Node.JS, specifically the 4.x and 6.x series runtimes.

Python

Python 3.7 and above.

The driver API is intended to be topologically agnostic. This means that the underlying database topology — single instance, Causal Cluster, etc. — can be altered without requiring a corresponding alteration to application code.

In the general case, only the connection URI needs to be modified when changes are made to the topology.

The official drivers do not support HTTP communication. If you need an HTTP driver, choose one of the community drivers.

See also the HTTP API documentation.

Driver versions and installation

Wherever possible, it is recommended to use the latest stable driver release available. This will provide the greatest degree of stability and will ensure that the full set of server functionality is available. The drivers, when used with Neo4j Enterprise Edition, come with full cluster routing support. The drivers make no explicit distinction between Enterprise Edition and Community Edition however, and simply operate with the functionality made available by Neo4j itself.

Example 1. Acquire the driver

To find the latest version of the driver, visit https://github.com/neo4j/neo4j-go-driver/releases.

To install the latest version of the driver using go get:

go get github.com/neo4j/neo4j-go-driver/v4

The release notes for this driver are available here.

A "Hello World" example

The example below shows the minimal configuration necessary to interact with Neo4j through the Go driver.

Example 2. Hello World
func helloWorld(ctx context.Context, uri, username, password string) (string, error) {
	driver, err := neo4j.NewDriverWithContext(uri, neo4j.BasicAuth(username, password, ""))
	if err != nil {
		return "", err
	}
	defer driver.Close(ctx)

	session := driver.NewSession(ctx, neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite})
	defer session.Close(ctx)

	greeting, err := session.ExecuteWrite(ctx, func(transaction neo4j.ManagedTransaction) (any, error) {
		result, err := transaction.Run(ctx,
			"CREATE (a:Greeting) SET a.message = $message RETURN a.message + ', from node ' + id(a)",
			map[string]any{"message": "hello, world"})
		if err != nil {
			return nil, err
		}

		if result.Next(ctx) {
			return result.Record().Values[0], nil
		}

		return nil, result.Err()
	})
	if err != nil {
		return "", err
	}

	return greeting.(string), nil
}

Driver API docs

For a comprehensive listing of all driver functionality, please see the Go API reference documentation.