Overview

Go is a programming language designed by Google. It is statically typed, meaning that the data types are checked during compilation of the source code, like Java.

 

Prerequisites

  • Operating System : Ubuntu 18 or higher

 

Steps

01. Download the installer from here [https://golang.org/dl/] or you can execute the following on a command line to get a specific version. In this case 1.12.5.

$ cd ~

$ wget https://dl.google.com/go/go1.12.5.linux-amd64.tar.gz

 

02. Unpack the installer to the /usr/local directory. Note that the target directory is just a suggestion.

$ sudo tar -C /usr/local -xzf go1.12.5.linux-amd64.tar.gz

03. Update the environment variable to include the go binaries included in the system path.

$ export PATH=$PATH:/usr/local/go/bin

04. To test that Go is installed correctly, we create a sample program.

$ cd ~

$ mkdir -p go/src/hello-geek

$ nano go/src/hello-geek/hello.go

Set the content as follow

package main

import "fmt"

func main() {

fmt.Printf("Hello, geek!\n")

}

 

05. Compile the source code

$ cd go/src/hello-geek/

$ go build

 

06. Run the generate executable file.

$ ./hello-geek

Previous PyCon 2019 | Keynote - Russell Keith-Magee
Next Google Cloud Next 2019 | Monitoring and Controlling Your GCP Costs