Go gvm and modules: outside GOPATH
If you are trying to create a module using go mod
and get an error similar to this:
go: cannot determine module path for source directory .../src/github.com/goliatone/go-dbus-notify (outside GOPATH, no import comments)
The error might be due to how go mod
tries to determine the module path: go mod init
with no arguments will try to get the module path from the current directory looking for a VCS repository's remote value.
e.g. If your project is not a git repo with a valid remote then it will fail to get the module path.
The solution is either to make it a repo... or use the explicit incantation:
$ go mod init github.com/goliatone/go-dbus-notify