go-mod
Go module dependency management
TLDR
Initialize new module
$ go mod init [module-name]
Download dependencies$ go mod download
Tidy dependencies$ go mod tidy
Vendor dependencies$ go mod vendor
Verify checksums$ go mod verify
SYNOPSIS
go mod command [arguments]
DESCRIPTION
go mod manages Go modules, the official dependency management system for Go. Modules are collections of packages with versioned dependencies defined in go.mod files.The command initializes modules, manages dependencies, and maintains reproducible builds. It integrates with module proxies and checksum databases to ensure package integrity and availability.
PARAMETERS
init NAME
Initialize new module.download
Download modules to cache.tidy
Add missing, remove unused.vendor
Create vendor directory.verify
Verify dependencies.graph
Print dependency graph.why PACKAGE
Explain why needed.--help
Display help information.
CONFIGURATION
go.mod
Module definition file containing module path, Go version, and dependency requirements.go.sum
Checksums of module dependencies for verification.GOSUMDB
Name of the checksum database used to verify downloaded modules; set to off to disable verification.GONOSUMDB
Glob patterns of module paths to exclude from checksum-database verification (defaults from GOPRIVATE if unset).GOFLAGS
Default flags applied to go commands, including go mod subcommands.
INSTALL
sudo apt install gccgo-go
sudo dnf install gcc-go
sudo pacman -S gcc-go
sudo apk add gcc-go
sudo zypper install gcc-go
brew install go
nix profile install nixpkgs#go
CAVEATS
Requires Go 1.11+. go.sum should be committed. Vendor mode for offline builds.
HISTORY
Go modules were introduced in Go 1.11 as the official dependency management solution, replacing GOPATH-based workflows.
