go install always attempts to use GOROOT and GOPATH is not listed under go env

前端 未结 4 1526
死守一世寂寞
死守一世寂寞 2020-12-31 13:19

I\'m having a quite frustrating problem with the GOPATH, which, despite being set in .profile, is not appearing when invoking go env,

4条回答
  •  太阳男子
    2020-12-31 14:19

    As you gave evidence for having set GOPATH, the second part of your question - GOPATH is not listed under go env - may be caused by the "go env" of your installed version. Neither go1 (linux) nor go1.0.2 (windows) versions of "go env" display GOPATH. If you look at the source (GOROOT/src/cmd/go/env.go), you'll find right at the top the list of elements to display (mkEnv) which starts with GOROOT and does not contain GOPATH.

    Version go1.0.3 (windows) does display GOPATH; the corresponding list in the source, however, starts with GOARCH.

    I admit that this does not solve the first part of your problem - (trying to) install into GOROOT - but perhaps the above will help you to focus on the culprit (build process).

提交回复
热议问题