解决Goland错误:$GOPATH/go.mod exists but should not

Posted 林猛男

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决Goland错误:$GOPATH/go.mod exists but should not相关的知识,希望对你有一定的参考价值。

一、遇到问题

执行main函数的时候,下面输出框报错:$GOPATH/go.mod exists but should not

二、解决办法(针对goland)

方案1:command+,打开软件偏好设置,然后找到GOPATH配置删掉项目GOPATH即可(推荐方案1)

方案2:将go目录下存在go.mod,删去即可

三、产生原因

开启Go module模块支持后,并不能与$GOPATH共存,所以把项目从$GOPATH中移出或者不要使用Go module模块即可

以上是关于解决Goland错误:$GOPATH/go.mod exists but should not的主要内容,如果未能解决你的问题,请参考以下文章

解决Goland错误:$GOPATH/go.mod exists but should not

解决Goland错误:$GOPATH/go.mod exists but should not

Goland 提示 Unresolved reference 错误解决

goland出现未定义Gotoot解决方法

Goland激活方法和问题解决

Goland 不能识别GOROOT解决办法