go mod init example.com/myappCreate a new go.mod for the current project. Useful in Go CLI workflows.
Go modules and go work workflows for init, tidy, vendor, replace, workspaces, private modules, and dependency management.
Modules Basics commands and patterns for the Go command.
go mod init example.com/myappCreate a new go.mod for the current project. Useful in Go CLI workflows.
go mod tidyAdd missing and remove unused module requirements. Useful in Go CLI workflows.
go mod downloadPre-fetch required modules into the module cache. Useful in Go CLI workflows.
go mod graphShow the module dependency graph. Useful in Go CLI workflows.
go mod why -m github.com/pkg/errorsShow why a package or module is needed. Useful in Go CLI workflows.
Editing and Replacements commands and patterns for the Go command.
go mod edit -replace example.com/lib=../libPoint a module dependency to a local checkout. Useful in Go CLI workflows.
go mod edit -require example.com/lib@v1.2.3Add an explicit module requirement. Useful in Go CLI workflows.
go mod edit -go=1.25Set the minimum Go version in go.mod. Useful in Go CLI workflows.
go mod vendorCopy dependencies into a vendor directory. Useful in Go CLI workflows.
go list -m -jsonInspect current module metadata. Useful in Go CLI workflows.
Dependency Updates commands and patterns for the Go command.
go get example.com/lib@latestUpdate a dependency to the latest version. Useful in Go CLI workflows.
go get -u=patch ./...Update a dependency within its compatible patch/minor range. Useful in Go CLI workflows.
go list -m -u allShow modules that have newer versions available. Useful in Go CLI workflows.
go mod verifyVerify dependencies in module cache against go.sum. Useful in Go CLI workflows.
go mod edit -exclude example.com/lib@v1.2.4Exclude a dependency version from selection. Useful in Go CLI workflows.
Private Modules commands and patterns for the Go command.
go env -w GOPRIVATE=github.com/myorg/*Mark private module path patterns. Useful in Go CLI workflows.
go env -w GONOPROXY=github.com/myorg/*Bypass proxy for selected module path patterns. Useful in Go CLI workflows.
go env -w GONOSUMDB=github.com/myorg/*Skip checksum database for selected private modules. Useful in Go CLI workflows.
go env -w GOVCS=github.com:git,private:allRestrict version control systems used for module fetches. Useful in Go CLI workflows.
Workspaces commands and patterns for the Go command.
go work initCreate a go.work file for multiple local modules. Useful in Go CLI workflows.
go work use ./app ./libAdd one or more modules to go.work. Useful in Go CLI workflows.
go work edit -jsonInspect go.work configuration as JSON. Useful in Go CLI workflows.
go work syncSync workspace dependencies back to module go.mod files. Useful in Go CLI workflows.
go work use -r .Add modules under a tree recursively. Useful in Go CLI workflows.