admin管理员组

文章数量:1612097

        GOROOT和GOPATH是个神奇的东西,现在还没有搞懂具体的差异在哪,可能以后有了实战经验后就能够解决了。

遇到的问题:

go: go.mod file not found in current directory or any parent directory; see 'go help modules'

背景:

环境变量:

 Hello.go文件:

  1. path中已经定位到GOROOT的bin目录下
  2. GOROOT的位置也是go的安装路径,因此环境变量的配置是没有问题的。
  3. 我的Hello.go文件是在GOPATH的路径下,并且文件是可以在vscode中成功运行的。
  4. 但在VSCode中一直报错为go: go.mod file not found in current directory or any parent directory; see 'go help modules'

解决方案:

cmd中输入:go env -w GO111MODULE=auto

至于报错的原因,还是因为GOPATH的问题,网上给出的答案到目前为止还是看不懂的。。。

本文标签: 解决方案CurrentfileModModules