Go – 导入 sql.a:不是一个包文件

huangapple go评论78阅读模式
英文:

Go - import sql.a: not a package file

问题

我正在使用go 1.3版本。当我尝试在golang中进行mysql连接时,在Linux控制台中运行正常。但是在使用go-ide 1.0时,出现以下错误:

"import
/home/gold/software/go-ide/bundled/go-sdk/pkg/linux_amd64/database/sql.a:
不是一个包文件"

请问有人可以建议我如何解决这个错误吗?

go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/local/go/bin:/home/gold/software/go-ide/bundled/go-sdk/bin"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

英文:

I am using go 1.3. When i try to do mysql connectivity in golang it's working fine in linux console. While trying to do the same using go-ide 1.0 it throws like

> "import
> /home/gold/software/go-ide/bundled/go-sdk/pkg/linux_amd64/database/sql.a:
> not a package file"

Any one please suggest me how to solve this error.

>go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/local/go/bin:/home/gold/software/go-ide/bundled/go-sdk/bin"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

答案1

得分: 1

对于go-ide我一无所知,但看起来这个IDE似乎附带了一个损坏的Go安装。

database/sql是一个标准包,编译后的文件应该在$GOROOT/pkg/linux_amd64/database/sql.a路径下。

根据你的错误信息,你的IDE似乎将GOROOT设置为/home/gold/software/go-ide/bundled/go-sdk

所以你要么修复该路径下的Go安装,要么告诉IDE真正的GOROOT路径。

英文:

Have no clue about go-ide but it looks like that IDE comes with a bundled go installation that is somehow broken.

database/sql is a standard package, the compiled file should be at$GOROOT/pkg/linux_amd64/database/sql.a.

According to your error message, your IDE somehow sets GOROOT to
/home/gold/software/go-ide/bundled/go-sdk.

So you either fix the go installation in that path or tell the IDE about the real GOROOT.

答案2

得分: 0

你的GOPATH不应该引用bin文件夹。
它应该引用父文件夹,在该文件夹中有bin/src/pkg/子文件夹。

英文:
GOPATH="/usr/local/go/bin:/home/gold/software/go-ide/bundled/go-sdk/bin"

Your GOPATH is not supposed to reference bin folders.
It should reference the parent folder, in which you have bin/, src/ and pkg/ sub-folders.

huangapple
  • 本文由 发表于 2014年8月5日 19:20:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/25137549.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定