liveBook · Manning

Go.mod file

A go.mod file is a Go module manifest that declares the module path, Go language version, and required dependencies.

How 3 Manning books explain it

Go in Action, Second Edition

A go.mod file is a Go module definition file that records the module path, Go language version, and module dependencies.

How it is used
Defines a module’s path and requirements for builds and dependency management.
How deep it goes
Shows initialization, file directives, versioned requirements, and dependency commands; does not detail the toolchain’s dependency-resolution internals.
Examples
Uses a wordcount module and a multi-module API project with direct and indirect requirements.
What you can do after
Operate/configure it with `go mod init`, `go get`, and `go mod tidy` to establish a module and manage requirements.

Read how Go in Action, Second Edition explains go.mod file →

Go in Practice, Second Edition

A go.mod file declares a Go module's module path, target Go version, and required dependencies.

How it is used
Identifies a Go module and records its target version and third-party dependencies during project setup.
How deep it goes
Explains how to create and maintain the file, but does not show its literal syntax or dependency entries.
Examples
Uses `go mod init hellogo` before creating a small HTTP server, and offers a repository URL path as a shareable alternative.
What you can do after
Operate/configure it with `go mod init`, `go get`, and `go mod tidy` to initialize a project and maintain dependency declarations.

Read how Go in Practice, Second Edition explains go.mod file →

Learn Go with Pocket-Sized Projects

go.mod is a Go module definition file that declares a module's path and dependency requirements.

How it is used
Configures a Go project as a module before application code is written.
How deep it goes
Explains creation and module naming, but does not detail dependency declarations or broader file syntax.
Examples
Uses hello-world and HTTP service projects initialized with learngo-pockets/hello and learngo/httpgordle.
What you can do after
Operate/configure a new Go project by creating its go.mod file with go mod init.

Read how Learn Go with Pocket-Sized Projects explains go.mod file →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.