如何解决“开始:警告:模块在GOPATH/src中被GO111MODULE = auto禁用" [英] How to fix "go get: warning: modules disabled by GO111MODULE=auto in GOPATH/src"

查看:120
本文介绍了如何解决“开始:警告:模块在GOPATH/src中被GO111MODULE = auto禁用"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下命令安装golint:go get -u golang.org/x/lint/golint.而且我认为我遇到两个问题:

I'm trying to install golint with the command: 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)

然后我尝试安装golang/tools,也失败了...

I then try to install golang/tools, also failed...

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)

推荐答案

在$ GOPATH/(在 $ GOPATH/go.mod <下)中似乎有一个 go.mod 文件/code>).您应该删除它.另外,由于您使用的是Go 1.11或更高版本,因此可以直接在GOPATH/任何包含 go.mod 文件的目录中运行 go get 命令父目录,然后该命令应该起作用.

It looks like you have a go.mod file inside $GOPATH/ (under $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.

这篇关于如何解决“开始:警告:模块在GOPATH/src中被GO111MODULE = auto禁用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆