tags: - golang - setup categories: - informational comments: true

date: 2021-12-26 00:00:00

DESCRIPTION

Go and Reproducible Builds

Install the Go compiler and write a few small programs to get familiar with the language. We will be using Go to implement parts of our network automation infrastructure.

The build output should be byte for byte reproducible from the inputs so we can recreate binaries and trace their provenance.

COMMANDS

Install asdf

sudo apt install –no-install-recommends git curl

git clone https://github.com/asdf-vm/asdf.git ~/.asdf
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.profile
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.profile
. ~/.profile

asdf

Install the Go Compiler

asdf plugin add golang
asdf list-all golang
asdf install golang 1.17.4

asdf global golang 1.17.4
asdf local golang 1.17.4

asdf plugin add golangci-lint
asdf list-all golangci-lint
asdf install golangci-lint 1.43.0

Write a Test Program

mkdir test
cd test
go mod init test

Programs

Write the following programs. We can review during the meeting.

  1. env(1)

Create a program which lists environment variables as ‘=’ delimited key/value pairs:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=e6a0557d8a1b
  1. ip(1)

Create a program which lists information about network interfaces:

  * interface name
  * MAC address
  * IP addresses
{Index:1 MTU:65536 Name:lo HardwareAddr: Flags:up|loopback}
  [127.0.0.1/32]

ERRORS

VERIFICATION