英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论