Last Update: Dec 26, 2022

Coding with AI

I wrote a book! Check out A Quick Guide to Coding with AI.
Become a super programmer!
Learn how to use Generative AI coding tools as a force multiplier for your career.


So if you want to develop Go in FreeBSD, you can certainly use pkg to automatically install binaries. But I like to do it manually. My reasons are simple, I want to have the latest and greatest version of Go the instant it’s released, and I like to have manual control over the versions, even install multiple versions sometimes.

Here’s how I do it on FreeBSD. (You can also watch a video)

So let’s first go to the Golang download page:

https://golang.org/dl/

We scroll down to where it says FreeBSD. At this time, we’re at 1.14.2

How to Install Go in FreeBSD

We’ll right-click and copy that link address.

Now we want to make a source directory. This can be any directory you want.

mkdir ~/src
cd ~/src

And we are going to use wget to download Go.

wget https://dl.google.com/go/go1.14.2.freebsd-amd64.tar.gz

This downloads the archive to our system. Let’s unzip it.

tar xvf go1.14.2.freebsd-amd64.tar.gz

Now that it’s unzipped, we can verify the files extracted.

How to Install Go in FreeBSD

Let’s move it to our local folder.

sudo mv go /usr/local

Now let’s open up our profile.

sudo vim ~/.profile

In that file, we want to add the following:

How to Install Go in FreeBSD

What we’re doing here is setting our go root to /usr/local/go:

export GOROOT=/usr/local/go

Then we’re setting our gopath to be in the “goprojects” directory in my home folder. This can be named anything you want.

export GOPATH=$HOME/goprojects

Then we’re putting the gopath and go root into our main path.

export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Then we’ll save that file.

Now let’s verify our installation.

go version

How to Install Go in FreeBSD

As you can see, we have go version 1.14.2 installed.

Then we’ll type in

go env

How to Install Go in FreeBSD

This will show us our go environment information.

Let’s do a quick hello world to verify our installation.

I’ll create a new file named test.go

vim test.go

And I’ll put in the following code (which is a fancy hello world)

package main

import (
    "fmt"
    "runtime"
)

func main() {
    fmt.Println("Hello from", runtime.GOOS)
}

And after saving and running the file:

How to Install Go in FreeBSD

There it is. Hello freebsd!

So this is how you install Go in FreeBSD. It’s that easy! You can update as frequently as you like and even run multiple versions in parallel.

If you want to learn more about Go or FreeBSD, subscribe to my tutorial updates below!


Want to become an expert Go programmer?

Learn Go Programming

You can boost your skills in a few weekends by taking these high quality Go courses taught by top experts!

We have over 30 hours of Go courses you can take now! You can try it for 10 days free of charge.


Click here for a free trial!



Stay up to date on the latest in Computer Vision and AI.

Get notified when I post new articles!

Intuit Mailchimp




Published: Apr 18, 2020 by Jeremy Morgan. Contact me before republishing this content.