In this article, we will install go on FreeBSD OS:
We'll use the OPNsense firewall as an example of FreeBSD OS.
OPNsense is an open-source, easy-to-use, and easy-to-build FreeBSD-based firewall and routing platform.
For downloading Golang on FreeBSD OS follow these steps:
1. Install Git
- $ sudo pkg update -f
- $ sudo pkg install git
2. Install Go
We'll install Go version "1.19.2" in this article.
Now we want to make a source directory. This can be any directory you want.
- $ mkdir ~/src
- $ cd ~/src
We are going to use "wget" to download Go
This downloads the archive to our system. Let’s unzip it.
- $ tar xvfgo1.19.2.src.tar.gz
Now that it’s unzipped, we can verify the files extracted.
Move it to our local folder.
- $ sudo mv go /usr/local
Now open up our profile with text editor. Install any text editor (ex: vim)
- $ pkg install vim
- $ sudo vim ~/.profile
In that file, we want to add the following:
1. we’re doing here is setting our go root to /usr/local/go:
- export GOROOT=/usr/local/go
2. Then we’re putting the gopath and go root into our main path.
- export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
- export PATH=$PATH:/usr/local/go/bin
- set path = ($path /usr/local/go/bin /root/.gopkg/bin)
Then we’ll save that file.
3. Now verify our installation.
- $ go version