Let’s Go with Neo4j

Setting up and using the Neo4j Go Driver

Vinodh Subramanian
Mar 23, 2019 · 3 min read

It’s been a while since the official Neo4j driver is available for Go. So I thought of giving it a try.

I’m used to working with windows but recently I started using Mac. And got used to problems while installing new software.

Though installing the Neo4j application is a straight forward job, establishing the connectivity from my Go project to Neo4j DB was tedious. There are a lot of things to be done to make it work. I found it quite difficult installing these drivers, other essential libraries and bridging the gap between them. So I’ve broken down the process and made it easy.

I guess you should have already installed Neo4j and Go in your Mac. If not please check Neo4j and Go installations for Mac OS.

The Go driver is built on top of the C Connector, Seabolt. So we need to have a cgo development environment.

Let’s get started with our work !!!


Linux provides pkg-config as part of the package management system. But, yeah you are right, Mac os doesn't. It’s simple to install though.

brew install pkg-config


Clone the Seabolt source from github. To build the project you’ll be needing a few libraries as well.

brew install cmake

brew install openssl

Create an environment variable named OPEN_SSL_ROOT_DIR. that points to the openssl library installation path (default is /usr/local/opt/openssl)

I keep all my vendor libraries in /Users/username/libraries. I’ve cloned the Seabolt source to the same path. You can proceed with your preferred directory.

cd /Users/username/libraries/seabolt-1.7


Add to the path

vim ~/.bash_profile

Add the following two variables to the profile

export PKG_CONFIG_PATH = /Users/username/libraries/seabolt-1.7/build/dist/share/pkgconfig

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Users/username/libraries/seabolt-1.7/build/dist/lib

You can make sure if the Seabolt library has been added to the pkg-config.

pkg-config --list-all

If you can see seabolt17-static seabolt17-static — The C Connector Library for Neo4j in the list of libraries, you are good to go.

Neo4j golang driver

Install the Neo4j golang driver.

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

We are done with all the requirements.

Let’s check whether our efforts have paid off

Start your Neo4j desktop application and get the bolt URL, username and password for your graph DB.

I’ve created a Graph named “neo4j”, password as “password” and it can be accessed in “bolt://localhost:7687” URL.

Create a file neo4jgolang.go. Add the following two code snippets to it. The code is self-explanatory.

The main function for go project
The function which creates driver, session and transaction to execute the Cypher query

I assume you’ve followed all the steps above. Now simply go ahead and execute your code

go run neo4jgolang.go

If all goes well you should be able to see the following response in the terminal.

“Welcome to world of Graphs
Greetings from graph : hello, world, from node 0”

In Neo4j browser, you will be able to see a Greeting node created with a message as “hello world”

So that’s it for this post. I’ve covered the basic and essential procedure to make your go project backed by Neo4j.

Hope you like it!!!

Neo4j Developer Blog

Developer Content around Graph Databases, Neo4j, Cypher, Data Science, Graph Analytics, GraphQL and more.

Vinodh Subramanian

Written by

Software engineer @ Dell Technologies and a Tech enthusiast. Working with Neo4j, RabbitMQ, Golang, Spring boot...

Neo4j Developer Blog

Developer Content around Graph Databases, Neo4j, Cypher, Data Science, Graph Analytics, GraphQL and more.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade