Oracle and Go on Windows 64-bit
I was looking to experiment some more with Go, and I wanted to setup a 64-bit environment for development. I found this site which offered a 32-bit installation but wanted to see if I could get a full 64-bit setup. These instructions are just an adaptation of those instructions.
Prerequisites:
- 64-bit Oracle Client (I used the 12.1 client)¹
- 64-bit golang installation
- 64-bit MinGW-64 installed
- Windows version of git installed
Setting up pkg-config:
Create a directory called c:\pkg-config and unzip the following files:
http://ftp.gnome.org/pub/gnome/binaries/win64/dependencies/gettext-runtime_0.18.1.1-2_win64.ziphttp://ftp.gnome.org/pub/gnome/binaries/win64/dependencies/pkg-config_0.23-2_win64.ziphttp://ftp.gnome.org/pub/gnome/binaries/win64/glib/2.26/glib_2.26.1-1_win64.zip
Create a new folder c:\pkg-config\PKG_CONFIG_PATH
And create this file as oci8.pc in that folder:
You will want to check the first line matches exactly your installation, most likely the user portion will be your username, and the version number may change based on your installation.
Environment Variables
You will want to make sure the /bin directory from your MinGW-64 installation is in your path, as well as c:\pkg-config\bin
You will also need to create a new variable PKG_CONFIG_PATH which should be set to C:\pkg-config\PKG_CONFIG_PATH
Installing ora
go get gopkg.in/rana/ora.v4
go install -v gopkg.in/rana/ora.v4
Sample Code Test
Make sure to change the connection string in sql.Open() and then go build the sourcefile you created. If everything works, the executable should show the query being run, and then the output (simply the username of the current user.)
[1] Need to test this process with an instant client, as most developers will likely only want to install the instant client.
For reference, here are the installed versions I used when creating this:
C:\>systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.15063 N/A Build 15063C:\>gcc --version
gcc (x86_64-posix-seh-rev2, Built by MinGW-W64 project) 7.1.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.C:\>go version
go version go1.8.3 windows/amd64C:\>tnspingTNS Ping Utility for 64-bit Windows: Version 12.1.0.2.0 - Production on 24-AUG-2017 09:13:00Copyright (c) 1997, 2014, Oracle. All rights reserved.TNS-03502: Insufficient arguments. Usage: tnsping <address> [<count>]C:\>git --version
git version 2.14.1.windows.1
