Disclaimer: I’m using Go version 1.12.7 for this. It may not work for earlier versions of Go.
If you’ve ever tried to get into Go, one of the first things you’ve probably struggled with is simply creating a Go module. Go likes to nag you about
$GOPATH, and as someone that is not a native Gopher, I don’t want to deal with it.
Ever run into this error when running
go mod init? I certainly have.
$ go mod init
go: cannot determine module path for source directory /some/path/... (outside GOPATH, no import comments)
In order to get past this, you can simply run this:
$ go mod init `pwd`
go: creating new go.mod: module /some/path/...
Credit goes to joshuamkite on GitHub here.