GO lang installation on FreeBSD

Working mostly on Windows 11 I found that cross compilation for FreeBSD does not work. I’ve got error message
go: unsupported GOOS/GOARCH pair FreeBSD/AMD64

Good solution is actually install it on FreeBSD itself. So here are commands from FreeBSD terminal.



#curl https://go.dev/dl/go1.19.3.freebsd-amd64.tar.gz -O
#cat go1.19.3.freebsd-amd64.tar.gz
<a href="https://dl.google.com/go/go1.19.3.freebsd-amd64.tar.gz">Found</a>.

#curl https://dl.google.com/go/go1.19.3.freebsd-amd64.tar.gz -O
#tar xvf go1.19.3.freebsd-amd64.tar.gz
#mv go /usr/local/.

$vi ~/.profile 
#add 3 env vars: export GOROOT=/usr/local/go export GOPATH=$HOME/goprojects export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
$ go version go version go1.19.3 freebsd/amd64 $ go env #to show go related env vars ... $ mkdir -p ~/goprojects/hello1 $ cd ~/goprojects/hello1 $ vi hello1.go
package main func main() { println("Hello One!") }
$go build hello1.go $./hello1 Hello One!
This entry was posted in golang, workday and tagged . Bookmark the permalink.

Leave a Reply