GoLang – Availing on Linux

Background

Let us avail the go runtime on our system.

 

Lineage

  1. OS
    • Microsoft – MS Windows
      Link

 

Linux

Though my primary OS is MS Windows, I play around a bit with Linux, as well.

Options

There are a couple of options for availing go on a Linux system.

The options include:-

  1. rpm
  2. tar.gz

We will go with fetching the tar from golang.

Outline

  1. Artifact
    • Identify Artifacts Source
    • Determine appropriate artifact
  2. Get Artifact
  3. Install or Avail Artifact
  4. Configure System

 

Artifacts

Identify Artifact Source

The artifacts are available here.

Images

Image – Featured Downloads

Image – Stable Versions

Determine Appropriate Artifact

Matrix

Here are the choices for a Linux Machine:-

Package OS Bitness
go1.15.linux-386.tar.gz x86 32-bit
go1.15.linux-amd64.tar.gz x86-64 64-bit
go1.15.linux-arm64.tar.gz ARMv8 64-bit
go1.15.linux-armv6l.tar.gz ARMv6 32-bit

 

Choice

We are running 64-bit Linux on an Intel/AMD Architecture.

And, so we will go with go1.15.linux-amd64.tar.gz.

 

Get Artifact

There are a couple of choices to download a file from a web server ( HTTP).

Choices

  1. wget

 

wget

Syntax


wget

Sample


wget --no-check-certificate -O /tmp/go1.15.linux-amd64.tar.gz https://golang.org/dl/go1.15.linux-amd64.tar.gz

 

Output

Output – Image

Output – Text


>wget --no-check-certificate -O /tmp/go1.15.linux-amd64.tar.gz https://golang.org/dl/go1.15.linux-amd64.tar.gz
--2020-08-30 11:23:53--  https://golang.org/dl/go1.15.linux-amd64.tar.gz
Resolving golang.org (golang.org)... 172.217.6.81, 2607:f8b0:4005:809::2011
Connecting to golang.org (golang.org)|172.217.6.81|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://dl.google.com/go/go1.15.linux-amd64.tar.gz [following]
--2020-08-30 11:23:54--  https://dl.google.com/go/go1.15.linux-amd64.tar.gz
Resolving dl.google.com (dl.google.com)... 172.217.6.78, 2607:f8b0:4005:807::200e
Connecting to dl.google.com (dl.google.com)|172.217.6.78|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 121136135 (116M) [application/octet-stream]
Saving to: ‘/tmp/go1.15.linux-amd64.tar.gz’

/tmp/go1.15.linux-amd64.tar.gz            100%[=====================================================================================>] 115.52M  3.47MB/s    in 33s

2020-08-30 11:24:27 (3.53 MB/s) - ‘/tmp/go1.15.linux-amd64.tar.gz’ saved [121136135/121136135]

>

 

 

Install or Avail Artifact

There are a couple of choices to install or avail files on Linux.

Choices

  1. Installer
    • rpm
  2. Extract Package
    • Extraction Tools
      • tar

 

Installer

rpm

  1. It seems that golang does not have an rpm file for Linux Installation.

Extract Package

Extraction Tool

tar

Syntax

sudo tar

Sample

sudo tar -C /usr/local -v -xzf go1.15.linux-amd64.tar.gz

 

Output
Output – Image

Output – Text

>sudo tar -C /usr/local -v -xzf go1.15.linux-amd64.tar.gz | more
go/
go/AUTHORS
go/CONTRIBUTING.md
go/CONTRIBUTORS
go/LICENSE
go/PATENTS
go/README.md
go/SECURITY.md
go/VERSION
go/api/
go/api/README
go/api/except.txt
go/api/go1.1.txt
go/api/go1.10.txt
go/api/go1.11.txt
go/api/go1.12.txt
go/api/go1.13.txt
go/api/go1.14.txt
go/api/go1.15.txt
go/api/go1.2.txt
go/api/go1.3.txt
go/api/go1.4.txt
go/api/go1.5.txt



Configure System

Outline

  1. Boundary
    • Entire System ( /etc/profile )
    • Self ( $HOME/.profile )
  2. Elements
    • Path
  3. Changes
    • OS – CentOS

Boundary

Decide on the boundary of what should be configured or affected.

If the entire system, please use ( /etc/profile ).

On the other hand, if you alone, ( $HOME/.profile ).

Elements

Here are the items that we will be configuring:-

  1. Path

 

Changes

System – /etc/profile
Outline
  1. Add a file to the /etc/profile.d folder
  2. The file should add /usr/local/go/bin to the system’s path
    • export PATH=$PATH:/usr/local/go/bin
  3. Execute Added File
    • source <file>

Add File to /etc/profile.d Folder

In our case, we will name the file ( /etc/profile.d/golangInstallSelf.sh ).

File Contents

>sudo cat /etc/profile.d/golangInstallSelf.sh
[sudo] password for dadeniji:
export PATH=$PATH:/usr/local/go/bin
>

 

Execute Loaded File

source <file>

Image


Validate

To validate installation:-

System ( /etc/profile )

  1. Initiate go

 

Syntax


go version

Sample


go version

Output

Output – Image

Output – Text


>go version
go version go1.15 linux/amd64
>

References

  1. GO
    • Getting Started
      Link
  2. ARM Architecture
  3. Oracle
    • Set Path on Unix
      Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s