Install Go on FreeBSD
| Update pkg | |
| Install with pkg | |
| go version | |
| Ports alternative |
Update pkg
Start by refreshing the binary package catalog so FreeBSD installs the current Go build.
sudo pkg update
This step only syncs repository metadata and changes nothing on disk yet.
Install with pkg
Install the language package from the official binary repository.
sudo pkg install lang/go
The package name uses the lang category prefix, which is the normal layout for programming languages on FreeBSD.
Accept the install prompt and wait for pkg to place the toolchain and manual pages.
go version
A fresh install should answer with its version number.
go version
go version go1.21 freebsd/amd64
If the command is not found, start a new shell so the PATH update from the package takes effect.
Ports alternative
Advanced users can also build Go from the ports tree when they need custom build options.
Beginners can safely ignore ports and stay with the binary package, since both methods provide the same go command.
Next: Go in Docker
Article author: Arthur Isaev