duanraa1984 2013-07-16 04:01
浏览 332
已采纳

去安装总是使用GOROOT / bin而不是GOPATH

I'm having annoying issue with go install command.

Every time I try to run it within the src directory of my GOPATH the resulted file is getting created in GOROOT/bin directory for some reason.

I verified my environmental variables in .bashrc and also run 'go env' (see below) and couldn't find any issues:

.bashrc

export GOBIN=$HOME/dev/src/go/bin
export GOPATH=$HOME/dev/go-dev
export PATH=$PATH:$GOBIN:$GOPATH/bin

go env

GOARCH="amd64"
GOBIN="/home/user/dev/src/go/bin"
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/dev/go-dev"
GORACE=""
GOROOT="/home/user/dev/src/go"
GOTOOLDIR="/home/user/dev/src/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CGO_ENABLED="1"

This post has a similar problem except I have GOPATH in my env (I tried the solution but it didn't help).

When I tried to create the test library using official GoLang site and run go install I've got a proper file created in $GOPATH/pgk/linux_amd64 but not in the bin directory.

Am I missing something in my configuration?

  • 写回答

1条回答 默认 最新

  • doushu7588 2013-07-16 04:17
    关注

    Official documentation about the go tool:

    If DIR is a directory listed in the GOPATH...

    If the GOBIN environment variable is set, commands are installed to the directory it names instead of DIR/bin

    There has been a discussion about this topic on the mailing list where this is further explained:

    (a) If you don't set your GOBIN env variable, you get the Go compiler binaries going in GOROOT/bin whereas the your binaries are going in GOPATH/bin. (I personally like this separation of binaries.)

    (b) If you set your GOBIN to anything, then both the Go binaries and your binaries are going to GOBIN.

    The solution in your case would be to not set your GOBIN.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序