go mod init

The go subcommand that starts a new module by writing a go.mod file with the module path you give it.

In more detail

Run it once in an empty folder: go mod init course.local/probe. The file it writes holds only the module path and the Go version until you add dependencies. There is no scaffolding step; that file plus one source file is a complete Go project.

Example

go mod init course.local/probe

Related terms

Taught in

References