GOPATH
is not recommended.GOPATH
.GOPATH
as the root of your project, and create a new module with the go mod init
command.go.mod
file will be generated, containing the module path, a Go version, and its dependency requirements, which are the other modules needed for a successful build.<modulepath>
is specified, go mod init
will try to guess the module path from the directory structure. It can also be overridden by supplying an argument.go.mod
file could look like this:go mod
commands.go fmt
. Your editor should be running this on every file save.