linuxgofedora

How do I fix $GOPATH/go.mod exists but should not - Linux Fedora


I am new to Golang, I am following this tutorial https://golang.org/doc/tutorial/getting-started but for some reason I keep getting this message every time I try to run the code:

$GOPATH/go.mod exists but should not

I have tried to look at answers like this one: https://stackoverflow.com/a/62062562/9785222 but I dont understand what is GOPATH and where is it.

I am using Vi as an editor on Linux Fedora


Solution

  • GOPATH defaults to $HOME/go on Unix.

    Remove the file $HOME/go/go.mod or explicitly set $GOPATH to a different directory.