This is a simple cheat sheet for go modules, listing the main commands.
Create a new module, with automatic module path resolution.
$ go mod init
go: creating new go.mod
Create a new module, with explicit module path.
$ go mod init github.com/my/repo
go: creating new go.mod: module github.com/my/repo
Prune any no-longer-needed dependencies and add any dependencies needed for other combinations of OS and architectures.
$ go mod tidy
Create a vendor directory with the exact version of the dependencies to use during build.
$ go mod vendor
Why a module or package is being kept.
go mod why module
Display the dependencies of your module.
go mod graph