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

Viewed 8871
2 Answers

GOPATH defaults to $HOME/go on Unix.

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

$GOPATH should point out to the src directory, in my case in Debian, I set $GOPATH to /usr/local/go/src and the problem was solved.

export $GOPATH=/usr/local/go/src

What is GOPATH ?

GOPATH is a variable that defines a folder, under which GO expects our code to reside . For more details, you can check this link

Related