go-oci8下载地址以及说明地址:https://github.com/wendal/go-oci
go-oci8官方说明
安装最新版的git,并设置可以从命令行直接调用git命令
这个步骤多一些
1234562.1 下载OCI最新版,存放于C:\instantclient_11_22.2 下载OCI SDK最新版,存放于C:\instantclient_11_2\sdk2.3 下载MinGW最新版,安装在C:\mingw2.4 下载pkg-config.exe和oci8.pc (已经存放在windows文件夹下)2.5 将pkg-config.exe复制到C:\mingw\bin\下2.6 将oci8.pc复制到C:\mingw\lib\pkg-config\下修改系统环境变量,添加
|
|
执行
go get github.com/wendal/go-oci8
其中第二步下载,可以在 这里 下载到,其中的环境已经配置好了
如果这一步没在go-oci8官方下载,而是和我当时一样,一步步去各个软件官网下载,那么要注意了
- 下载并安装完之后,需要修改oci8.pc;
|
|
这个包是不支持win x64的,我也没测试64位版本的安装
这时候,
go get github.com/wendal/go-oci
如果和我一样出现了
1234567C:\Documents and Settings\Administrator>go get github.com/wendal/go-oci8# github.com/wendal/go-oci8C:\GoPath\src\github.com\wendal\go-oci8\oci8.go:119: cannot use (**C.struct_OCIS erver)(unsafe.Pointer(&conn.svc)) (type **C.struct_OCIServer) as type **C.struct_OCISvcCtx in argument to _Cfunc_OCILogonC:\GoPath\src\github.com\wendal\go-oci8\oci8.go:136: cannot use (*C.struct_OCIServer)(c.svc) (type *C.struct_OCIServer) as type *C.struct_OCISvcCtx in argument to _Cfunc_OCILogoffC:\GoPath\src\github.com\wendal\go-oci8\oci8.go:263: cannot use (*C.struct_OCIServer)(s.c.svc) (type *C.struct_OCIServer) as type *C.struct_OCISvcCtx in argument to _Cfunc_OCIStmtExecuteC:\GoPath\src\github.com\wendal\go-oci8\oci8.go:383: cannot use (*C.struct_OCIServer)(s.c.svc) (type *C.struct_OCIServer) as type *C.struct_OCISvcCtx in argument to _Cfunc_OCIStmtExecute
这样的出错提示,表示你安装的oci版本和go-oci8不一致,这个时候找到
%GOPATH%\src\github.com\wendal\go-oci8\oci8.go
文件有4个地方需要修改
- 119行
|
|
- 136行
|
|
- 263行
|
|
- 383行
|
|
或者直接替换OCIServer为OCISvcCtx。 重新执行
1
go get github.com/wendal/go-oci
搞定收工。