3. Golang setup on FeeBSD 11.2 - tanalam2411/freebsd GitHub Wiki

Golang setup on FeeBSD 11.2

Referred - https://www.vultr.com/docs/nginx-reverse-proxy-and-golang-setup-on-freebsd

https://medium.com/@firebitsbr/install-go1-10-1-freebsd-amd64-and-setting-gopath-on-freebsd-11-1-x86-64-b5334f36fb2

  1. Install dependencies
[root@ ~/performance/timescaledb]# pkg install wget bzr
  1. Download Go from https://golang.org/dl/#stable kind = Archive, OS = FreeBSD, Arch = x86-64
[root@ ~/performance/timescaledb]# wget https://dl.google.com/go/go1.11.2.freebsd-amd64.tar.gz
  1. Extract it at location /usr/local
[root@ ~/performance/timescaledb]# tar -C /usr/local/ -xzf go1.11.2.freebsd-amd64.tar.gz
  1. Setup Environment Variables

Create a variable called GOPATH (which will be the location for installed packages) and add it to your path

[root@ ~/performance/timescaledb]# mkdir ~/.gopkg
[root@ ~/performance/timescaledb]# echo "setenv GOPATH /root/.gopkg" >> ~/.cshrc
[root@ ~/performance/timescaledb]# echo "set path = ($path /usr/local/go/bin /root/.gopkg/bin)" >> ~/.cshrc

You can verify GOPATH and set path got updated in ~/.cshrc file

[root@ ~/performance/timescaledb]# vi ~/.cshrc
----------------------------------------------------
# should have these two entries at the end
setenv GOPATH /root/.gopkg
set path = ( /usr/local/go/bin /root/.gopkg/bin)
----------------------------------------------------

If your using bash shell

export GOPATH="/root/.gopkg"
export PATH=$PATH:/usr/local/go/bin:/root/.gopkg/bin