Connect a Go application to Neon
Set up a Neon project in seconds and connect from a Go application
To connect to Neon from a Go application:
Create a Neon project
If you do not have one already, create a Neon project. Save your connection details including your password. They are required when defining connection settings.
To create a Neon project:
- Navigate to the Projects page in the Neon Console.
- Click New Project.
- Specify your project settings and click Create Project.
Configure Go application connection settings
Connecting to Neon requires configuring connection settings in your Go project's
Neon is fully compatible with the
sql/db package and common Postgres drivers, such as
Specify the connection settings in your
.go file, as shown in the following example:
<user>is the database user.
<password>is the database user's password.
<dbname>is the name of the database. The default Neon database is
<hostname>is the hostname of the branch's compute endpoint. The hostname has an
ep-prefix and appears similar to this:
You can find all of the connection details listed above in the Connection Details widget on the Neon Dashboard. For more information, see Connect from any application.