Go.mod file
A go.mod file is a Go module manifest that declares the module path, Go language version, and required dependencies.
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 modules and tracks their dependencies as projects grow into separately managed components.
- How deep it goes
- Explains initialization, module paths, dependency entries, maintenance commands, and checksums, while deferring broader go command coverage.
- Examples
- Uses a wordcount module and a multi-module news project with direct and indirect dependencies.
- What you can do after
- Operate and configure a Go module using go mod init, go get, and go mod tidy.
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 →
Also covered in
What to know first
- GoGo is a statically typed, compiled, general-purpose programming language with garbage collection and built-in support for concurrency.
- packageA software package is a named unit that groups related software components, either for organization and compilation or for distribution and reuse.
Related concepts
- go mod initproduced by · go mod init is a Go command that initializes a module by creating its go.mod file with a specified module path.
- go moduleconfigures · A Go module is a versioned collection of related Go packages defined by a go.mod file and managed as a unit for dependency resolution and builds.
- go commandconfigures · The go command is Go’s standard command-line interface for compiling, building, testing, formatting, analyzing, and managing Go programs and dependencies.
- go mod tidyproduced by · go mod tidy is a Go command that synchronizes declared module dependencies and checksums with the packages imported by the source code.
Questions about go.mod file
What is go.mod file?
A go.mod file is a Go module manifest that declares the module path, Go language version, and required dependencies.
Which Manning books explain go.mod file?
Go in Action, Second Edition, Go in Practice, Second Edition and Learn Go with Pocket-Sized Projects.
What should I know before learning go.mod file?
Manning books that teach go.mod file usually introduce Go and package first.
What are the parts of go.mod file?
Go.mod file includes go directive and module directive.
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.


