douzi8548 2016-09-03 21:13
浏览 12
已采纳

Go会忽略导出的GOPATH

I followed the linux go installation instructions and ran sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz and added /usr/local/go/binto $PATH. Unfortunately, I am stuck because go ignores any attempt to export $GOPATH in the terminal. What's going on and how can I fix it?

$ export GOPATH=$HOME/Go
$ echo $GOPATH
/home/rsg/Go
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build834345994=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

Edit: On further inspection, it seems that for some reason, I am unable to export GOPATH at all. I am not sure why, because exporting other variables (e.g. FOO) works just fine. What on earth is going on?

rsg@P ~ $ env | grep FOO
rsg@P ~ $ env | grep GOPATH
rsg@P ~ $ export FOO=bar
rsg@P ~ $ env | grep FOO
FOO=bar
rsg@P ~ $ export GOPATH=bar
rsg@P ~ $ env | grep GOPATH
rsg@P ~ $ GOPATH=foo env | grep GOPATH
GOPATH=foo
rsg@P ~ $ env | grep GOPATH
  • 写回答

1条回答 默认 最新

  • doutang3815 2016-09-03 21:38
    关注

    I still have no idea what the problem was, but running unset GOPATH fixed it.

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

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊