Install Go
There are 2 ways to install Golang on your workstation, using a packager manager, or by getting it directly from the official website. I recommend downloading it directly, if you want to guarantee that you get the latest version of Go. Package managers often ends up installing a slightly older version because there’s usually a delay for the latest versions of Go getting packaged up and made available to the various package managers.
Install Golang via a package manager
You can install go with your favourite package manager.
RHEL/CentOS:
dnf install golang
Ubuntu/Debain:
apt update
apt install golang
MacOS:
brew install golang
Windows:
winget install -e --id GoLang.Go.1.18
Verifying your Golang install
Once you’ve done the install, The go binary should be installed somewhere on your filesystem:
$ which go
/usr/local/go/bin/go
$ ls -l /usr/local/go/bin
total 37200
-rwxr-xr-x 1 root wheel 15610144 29 Mar 22:48 go
-rwxr-xr-x 1 root wheel 3429584 29 Mar 22:48 gofmt
Notice that we also get the gofmt
binary installed as part of install Golang. That’s used for formatting your go code.
You should now be able to access go from your terminal:
$ go version
go version go1.20.3 darwin/amd64
$ go help
$ go version
go version go1.13.8 linux/amd64$ go help
Go is a tool for managing Go source code.Usage:go <command> [arguments]The commands are:bug start a bug report
build compile packages and dependencies
clean remove object files and cached files
doc show documentation for package or symbol
...