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/probeRelated terms
- go.mod — The text file at the root of a Go module that records its module path, the Go version it needs and the other modules it depends on.
- module path — The name a Go module declares in its go.mod file, which is also the prefix of every import path inside it.
- Go module — A tree of Go packages that is versioned and released together, described by a go.mod file at its root.
Taught in
- Go Workspaces and Modules — Concurrent Systems Programming with Go