Go

This guide provides a walk-through of how to install the latest version of Go along with the MQTT Client library.

Installing Go

Make sure git is installed to be able to complete setup

sudo apt-get install git

The current stable version available at Go official website is v1.15

  • Type the following command to download the Go binary release

ARMv8
ARMv6
ARMv8

For 64-bit ARM OS

wget https://golang.org/dl/go1.15.linux-arm64.tar.gz
ARMv6

For 32-bit ARM OS

wget https://golang.org/dl/go1.15.linux-armv6l.tar.gz
  • Decompress the downloaded package and move it to /usr/local directory

ARMv8
ARMv6
ARMv8
sudo tar -C /usr/local -xzf go1.15.linux-arm64.tar.gz
ARMv6
sudo tar -C /usr/local -xzf go1.15.linux-armv6l.tar.gz
  • PATH environment variables that are required need to be added for the system to recognize where the Go is installed. To do that, edit the ~/.profile file

nano ~/.profile
  • Add the following to the end of the file

PATH=$PATH:/usr/local/go/bin
GOPATH=$HOME/golang
  • Finally, make the system aware of the new profile

source ~/.profile
  • Type which go to find out where the Go binary installed and go version to see the installed version and the platform.

$ which go
/usr/local/go/bin/go
$ go version
go version go1.15 linux/arm64

Installing MQTT Client

This documentation uses the Paho MQTT client as a client library.

Install Go library by running the following command:

go get github.com/eclipse/paho.mqtt.golang

Connect Device

Start connecting devices by following the guide :