Dependency management organizes the components a Go project needs so they can be resolved, versioned, fetched, and built reproducibly. Go modules use go.mod for module identity and requirements, while go.sum records cryptographic checksums for dependency source and metadata. section 11.1
A practical module workflow includes:
- Initialize a module with go mod init and choose a module path matching its repository location. section 11.1
- Add dependencies explicitly with go get, or import them in code and run go mod tidy. section 11.1
- Pin direct and transitive requirements in go.mod and verify their contents through go.sum checksums. section 11.1
Module requirements
An API module can require a shared domain module and github.com/gorilla/mux at declared versions, while recording other dependencies as indirect requirements. section 11.1
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
)
Inspect a concrete go.mod file showing the module declaration, Go version, direct requirements, and an indirect transitive dependency. section 11.1




