How do you install the Neo4j Go Driver and create a new driver instance?
Install the driver
Complete the shell command to install the Neo4j Go Driver.
go get #select:github.com/neo4j/neo4j-go-driver/v5
-
❏ github.com/neo4j/neo4j-go-driver
-
❏ neo4j-go-driver
-
✓ github.com/neo4j/neo4j-go-driver/v5
-
❏ neo4j
Hint
You can find the package name on GitHub.
Solution
The correct answer is github.com/neo4j/neo4j-go-driver/v5
.
go get github.com/neo4j/neo4j-go-driver/v5
Create a new driver instance
Great work! With the driver installed, you can now create a new driver instance.
Complete the code below to create a new driver instance.
import "github.com/neo4j/neo4j-go-driver/v5/neo4j"
NEO4J_URI := "neo4j://localhost:7687"
NEO4J_USERNAME := "neo4j"
NEO4J_PASSWORD := "letmein"
driver, err := neo4j./*select: NewDriverWithContext() */(
NEO4J_URI,
neo4j.BasicAuth(NEO4J_USERNAME, NEO4J_PASSWORD, "")
)
-
❏ Connect
-
✓ NewDriverWithContext
-
❏ Driver
-
❏ NewConnection
Hint
What is the name of the function used to create a new Neo4j driver instance?
Solution
The function to create a new connection is neo4j.NewDriverWithContext()
.
driver, err := neo4j.NewDriverWithContext(
NEO4J_URI,
neo4j.BasicAuth(NEO4J_USERNAME, NEO4J_PASSWORD, "")
)
Summary
You can now install the github.com/neo4j/neo4j-go-driver/v5
package and connect to Neo4j by creating a new driver instance.
In the next lesson, you will learn how to execute your first Cypher query.