1. linux下先装好
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
rpm -ivh oracle-instantclient11.2-basic-12.1.0.2.0.x86_64.rpm
rpm -ivh oracle-instantclient11.2-sqlplus-12.1.0.2.0.x86_64.rpm
export ORACLE_HOME=/usr/lib/oracle/12.1/client64
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
sqlplus "scott/xxx@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.11.149)(PORT=1521))(CONNECT_DATA=(SID=orcl)))"
2.
sudo ln -s /usr/include/oracle/12.1/client64 $ORACLE_HOME/include
export PKG_CONFIG_PATH=~/pkg_config_path
vi ~/pkg_config_path/oci8.pc
oci8.pc view https://github.com/mattn/go-oci8
go get github.com/mattn/go-oci8
3. test
https://github.com/wendal/go-oci8/blob/master/example/oracle.go
key:
db, err := sql.Open("oci8", "scott/tiger@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.11.149)(PORT=1521))(CONNECT_DATA=(SID=orcl)))")
https://help.ubuntu.com/community/Oracle%20Instant%20Client
有疑问加站长微信联系(非本文作者)