Go 1 cheatsheet
Go 1: Modules and dependencies
10 common Go 1 tasks.
Add a dependency
Add a module at its latest version to go.mod.
go get github.com/gin-gonic/gin@latest
Download all dependencies
Download modules to the module cache, as CI and Docker builds do.
go mod download
Update all dependencies
Upgrade the dependencies of your packages to their newest minor or patch versions.
go get -u ./...
Find out why a module is needed
Show the import chain that requires a module.
go mod why github.com/pkg/errors
Use a local copy of a module
Point a dependency at a folder on disk while you develop it.
go mod edit -replace example.com/lib=../lib
Vendor dependencies
Copy dependencies into a vendor folder for reproducible offline builds.
go mod vendor
Create a workspace
Work on several modules together without editing their go.mod files.
go work init ./app ./lib