Install Go and the Godror driver
To connect to Autonomous Database from your Go application, install Go and the godror
driver.
- Download and install Go based on your operating system and the version of the operating system. This method installs from precompiled binary packages.Note
These steps describe installation of Go application for Microsoft Windows operating system. For Linux and Mac operating system, you can check out the link mentioned in this step. - Open the MSI file you downloaded and follow the prompts to download Go. The installer will install the
godror
driver. - Go to Program Files (x86).After installing, close and reopen any open command prompts so that changes to the environment made by the installer are reflected at the command prompt.
- Verify that you've installed Go.
-
In Windows, click the Start menu.
-
In the menu's search box, type
cmd
, then press the Enter key. -
In the Command Prompt window that appears, type the following command:
go version
-
Confirm that the command prints the installed version of Go.
-
- Install
godror
:To installgodror
, run the following command:go get github.com/godror/godror
Godror
is an open source database package in Go that allows a Go application user to connect and work with Autonomous Database using ODPI-C.See Go DRiver for ORacle User Guide (godror) for additional tips on installation.
- Install an Oracle Client library to use
Godror
.Godror
uses Oracle Database Programming Interface for C (ODPI-C) which supports connection to Oracle databases.Follow the ODPI-C installation instructions to install and configure the Oracle client libraries.
You can use the optional
libDir
parameter to specify the Oracle Client library directory on macOS and Windows. For example,db, err := sql.Open("godror", `user="scott" password="tiger" connectString="dbhost:1521/orclpdb1" libDir="/Users/myname/instantclient_19_3"`)
In this example, the
libDir
parameter value is set to the path to the location where you unzip the Oracle Instant Client zip files.Note
Oracle recommends you keep up to date with Go and
godror
releases.
Parent topic: Connect Go Applications to Autonomous Database