Code-Memo

Managing dependencies

Install Go

Download a stable release from https://go.dev/dl/ or use your package manager.

Windows
go version
macOS
brew install go
go version
Linux (Debian/Ubuntu example)
sudo apt update
sudo apt install golang-go   # distro version may lag

Or install a tarball from go.dev/dl into /usr/local/go and add /usr/local/go/bin to PATH.

Modules

Initialize a module in your project root:

go mod init example.com/myapp

Dependencies are recorded in go.mod; checksums in go.sum. Commit both.

Add or upgrade a dependency
go get golang.org/x/sync@latest
go mod tidy
Vendor (optional)
go mod vendor

Build with -mod=vendor to use the vendor/ tree (common in CI reproducibility).

Private modules

Set GOPRIVATE for domains that should not hit the public checksum database:

go env -w GOPRIVATE=*.corp.example
Workspaces (multi-module local dev)
go work init ./app ./lib

Proxy

Default GOPROXY uses proxy.golang.org. Air-gapped environments run their own module proxy or direct GOPROXY=direct.