[英]How to fix "go get: warning: modules disabled by GO111MODULE=auto in GOPATH/src"
I'm trying to install golint with the command: go get -u golang.org/x/lint/golint.我正在尝试使用以下命令安装 golint:go get -u golang.org/x/lint/golint。 And I think I got two problems:
我想我有两个问题:
go get: warning:
modules disabled by GO111MODULE=auto in GOPATH/src;
ignoring ../go.mod;
see 'go help modules'
package golang.org/x/lint/golint:
unrecognized import path "golang.org/x/lint/golint" (https fetch: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.58.200.192:443: i/o timeout)
I then try to install golang/tools, also failed...然后我尝试安装golang/tools,也失败了...
package golang.org/x/tools: unrecognized import path "golang.org/x/tools" (https fetch: Get https://golang.org/x/tools?go-get=1: dial tcp 216.58.200.192:443: i/o timeout)
I ran this command我运行了这个命令
export GO111MODULE="on"
and that worked for me...这对我有用......
Also got this error when trying to work with vgo
尝试使用
vgo
时也出现此错误
Removing GOROOT (you don't need to explicitly set GOROOT
, Modern versions of Go can figure it out on their own based on the location of the go binary that you run), updating my GOPATH and export GO111MODULE="on"
resolved the issue.删除 GOROOT(您不需要显式设置
GOROOT
,Go 的现代版本可以根据您运行的 go 二进制文件的位置自行解决),更新我的 GOPATH 并export GO111MODULE="on"
解决了该问题.
GOPATH see in here GOPATH 请看这里
GOPATH may be set to a colon-separated list of paths inside which Go code, package objects, and executables may be found.
GOPATH 可以设置为以冒号分隔的路径列表,其中可以找到 Go 代码、包对象和可执行文件。
Set a GOPATH to use goinstall to build and install your own code and external libraries outside of the Go tree (and to avoid writing Makefiles).
设置 GOPATH 以使用 goinstall 在 Go 树之外构建和安装您自己的代码和外部库(并避免编写 Makefile)。
It looks like you have a go.mod
file inside $GOPATH/ (under $GOPATH/go.mod
).看起来您在 $GOPATH/ 中有一个
go.mod
文件(在$GOPATH/go.mod
)。 You should remove that.你应该删除它。 Also, since you are using Go 1.11 or newer, you can run the
go get
command from well outside of GOPATH/any directory containing a go.mod
file either directly or in a parent directory, and then the command should work.此外,由于您使用的是 Go 1.11 或更高版本,因此您可以直接或在父目录中从 GOPATH/任何包含
go.mod
文件的目录之外运行go get
命令,然后该命令应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.