linuxgo

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


I just updated to the new version of Go - Go version 1.16.2 Linux/amd64 and am getting an error when I build a Hello, World! example:

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

Even when I follow the fix from that post it isn't working. I set these variables and then build again:

GO111MODULE=on
GOPROXY=https://proxy.golang.org,direct

And the same problem unfortunately.


Solution

  • Yes, just follow the tutorial and for me that was doing go mod init test3 to create a module. No one else has been upgrading from the old version or everyone else just understood it properly I guess.