Install go
https://go.dev/doc/toolchain
/usr/local/go # installation dir
/usr/local/go/bin/go # binary location
Install go
wget -c https://go.dev/dl/go1.25.6.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.25.6.linux-amd64.tar.gz
go version
Change GOPATH
# in ~/.bashrc
export GOPATH=$HOME/bin/go
export PATH=$PATH:$GOPATH/bin
Update go (change version)
# update to go1.25.6
go env -w GOTOOLCHAIN=go1.25.6+auto
Uninstall go
sudo rm -fr /usr/local/go
# then remove go from $PATH
Start a program
go mod init myproject/example
go mod tidy
go help mod
go mod <command> [arguments]
The commands are:
download download modules to local cache
edit edit go.mod from tools or scripts
graph print module requirement graph
init initialize new module in current directory
tidy add missing and remove unused modules
vendor make vendored copy of dependencies
verify verify dependencies have expected content
why explain why packages or modules are needed