Install Go and the Godror driver

To connect to Autonomous Database from your Go application, install Go and the godror driver.

  1. 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.
  2. Open the MSI file you downloaded and follow the prompts to download Go. The installer will install the godror driver.
  3. 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.
  4. 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.

  5. Install godror:
    To install godror, 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.

  6. 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.