A Go module groups one or more packages into a named project that Go can build and manage as a unit. Its root directory contains go.mod, which identifies the module and records information needed to resolve dependencies. A module can be a reusable library or an installable application. section 2.3.2 section 11.0
Start a module
Create a wordcount directory, enter it, and run `go mod init gobook/wordcount`. The resulting go.mod begins with `module gobook/wordcount` and `go 1.25`. The go command consults that file when building code in the module directory and its subdirectories. This new project has no external dependencies yet. section 2.3.1 section 2.3.2
As the project grows, go.mod can list required modules and their versions, including indirect dependencies. `go get` can request a latest or specific version; `go.sum` holds cryptographic information for dependency verification. Modules use semantic versions, so dependencies can be managed as projects change. section 11.1 section 11.4
module github.com/YOUR_USERNAME/go-news/api #1
go 1.25 #2
require ( #3
github.com/YOUR_USERNAME/go-news/domain v0.0.1
github.com/gorilla/mux v1.8.0
)
require (
github.com/other/transitive v0.5.2 // indirect #4
)
A service module’s go.mod shows its module path, Go version, direct requirements, and an indirect requirement. section 11.1
Module boundaries become useful when components need to evolve separately. An RSS reader can split its shared domain model, storage, REST API, and background worker into four modules. During local development, a workspace coordinates changes across modules through go.work without requiring each change to be published as a new version. section 11.0 section 11.4



