Go get path is a GOROOT, not a GOPATH error, even with env set up in Windows

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

Go get path is a GOROOT, not a GOPATH error, even with env set up in Windows

问题

在Windows 8中,每当我尝试使用go getgo install下载软件包时,我会遇到以下错误:

无法下载,C:\Users\MYUSER\go是GOROOT,而不是GOPATH。有关详细信息,请参阅:'go help gopath'

我已经手动设置了计算机和当前用户的环境变量GOPATH、GOROOT和GOTOOLDIR,但没有成功。

用户的go env:

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\MYUSER\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

管理员提示符的go env:

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\MYUSER\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

这是go get的已知问题,还是我在设置方面还是做错了什么?提前感谢您的帮助!

英文:

In Windows 8, whenever I try to download a package with go get and go install I get the following error:

cannot download, C:\Users\MYUSER\go is a GOROOT, not a GOPATH. For more details see: 'go help gopath'

I had manually set up the environment variables GOPATH, GOROOT and GOTOOLDIR for both the computer and the current user to no avail

User go env

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\MYUSER\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

Administrator prompt go env

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\MYUSER\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

Is this a known issue with go get or I'm still doing something wrong with my setup? Thanks in advance

答案1

得分: 6

原来,go get命令会检查文件"src/cmd/go/alldocs.go"以验证路径是否为goroot。我提出了一个关于这种严格检查的问题,但是它以"不会修复"的方式被关闭了。至少可以使用不同的错误消息,但这就是目前的工作方式。

英文:

As it turns out, go get checks for the file "src/cmd/go/alldocs.go" to verify that the path is goroot. I opened an issue about the aggressive check but it was closed in a "won't fix" fashion. At least it could use a different error message, but that's how it works as of today

huangapple
  • 本文由 发表于 2017年4月18日 01:17:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/43456135.html
匿名

发表评论

匿名网友

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

确定