如何修复 $GOPATH/go.mod 存在但不应该存在的问题 - Linux Fedora

Nic*_*Nic 13 linux fedora go

我是 Golang 新手,我正在关注本教程https://golang.org/doc/tutorial/getting-started但由于某种原因,我每次尝试运行代码时都会收到此消息:

$GOPATH/go.mod exists but should not

我试图查看这样的答案: https: //stackoverflow.com/a/62062562/9785222,但我不明白什么是 GOPATH 以及它在哪里。

我在 Linux Fedora 上使用 Vi 作为编辑器

Cer*_*món 6

GOPATH在 Unix 上默认为 $HOME/go。

删除文件 $HOME/go/go.mod 或显式将 $GOPATH 设置为其他目录。