golang连接orcale数据库


Orcale安装在远程服务器中,采用docker-compose部署,Navicat连接成功。版本为12.1.0.2.0


本机系统为:macOS Sierra

版本:10.12.6

golang环境:

安装:

instantclient-basic-macos.x64-12.1.0.2.0.zip

instantclient-sdk-macos.x64-12.2.0.1.0-2.zip

instantclient-sqlplus-macos.x64-12.1.0.2.0.zip


instantclient_12_1放在/Users/yuyang/Downloads目录下


环境变量配置:

LD_LIBRARY_PATH=/Users/yuyang/Downloads/instantclient_12_1

PKG_CONFIG_PATH=/Users/yuyang/Downloads/instantclient_12_1


oci8.pc文件内容为


prefixdir=/Users/yuyang/Downloads/instantclient_12_1/

libdir=${prefixdir}

includedir=${prefixdir}/sdk/include


Name: OCI

Description: Oracle database driver

Version: 12.1

Libs: -L${libdir} -lclntsh

Cflags: -I${includedir}



连接目录为/usr/lib



现在的问题是运行连接程序的时候报错:



panic: OCIEnvCreate error


goroutine 1 [running]:

exit status 2