How to install Golang in FreeBSD in 5 minutes
Tags: beginners, go, unix, programming
Published: 2020-04-18 20:55:08

---
title: How to install Golang in FreeBSD in 5 minutes
published: true
description: How to manually install the latest version of Go in FreeBSD 12
tags: beginner, go, Unix, programming
canonical_url: https://www.jeremymorgan.com/tutorials/golang/how-to-install-go-freebsd/
---

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 like 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.

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

**[https://golang.org/dl/](https://golang.org/dl/)**

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

![How to Install Go in FreeBSD](https://dev-to-uploads.s3.amazonaws.com/i/9ctawdx40w8ip8k02plm.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/i/u6s7ka5e6tbbnibedqf7.jpg)


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](https://dev-to-uploads.s3.amazonaws.com/i/6mj6csnqgx3g0cv83hu7.jpg)

Wat 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 go path 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](https://dev-to-uploads.s3.amazonaws.com/i/loxlqpui593kndfdgxfl.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/i/3w6u94nybug4uq0akodq.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/i/mneyctt4jtjgpclb6igq.jpg)

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, follow me here on Dev.To!!