YouTube Icon

Code Playground.

How to Install Go on Ubuntu 18.04

CFG

How to Install Go on Ubuntu 18.04

Go is a cutting edge open-source programming language made by Google. Numerous mainstream applications, including Kubernetes, Docker, and Grafana are written in Go. 

This instructional exercise will manage you through the means of downloading and introducing Go on a Ubuntu 18.04 machine. 

Prerequisites

Prior to proceeding with this instructional exercise, ensure you are signed in as a client with sudo advantages . 

Installing Go on Ubuntu

Follow the means underneath to introduce Go on Ubuntu 18.04: 

1. Downloading the Go tarball

At the hour of composing this article, the most recent stable form of Go is rendition 1.13. Prior to downloading the tarball, visit the authority Go downloads page and check if there is another form accessible. 

To download the Go parallel, you can utilize either wget or twist : 

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

2. Verifying the Go tarball

To confirm the tarball checksum you can utilize the sha256sum order: 

sha256sum go1.13.linux-amd64.tar.gz

The yield will look something like this: 

68a2297eb099d1a76097905a2ce334e3155004ec08cdea85f24527be3c48e856  go1.13.linux-amd64.tar.gz

Ensure the hash printed from the order above matches the one from the downloads page. 

3. Extracting the Go tarball

Use tar to remove the tarball to the/usr/nearby registry: 

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

4. Adjusting the Path Variable

All together for the framework to realize where to locate the Go executable pairs, we need to change the $PATH climate variable. We can do this by annexing the accompanying line to the/and so forth/profile document (for a framework wide establishment) or the $HOME/.profile record (for a current client establishment): 

~/.profile

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

Save the record, and burden the new PATH climate variable into the current shell meeting: 

source ~/.profile

5. Verifying the Go Installation

Check the establishment by printing the Go adaptation: 

go version

The yield should look something like this: 

go version go1.13 linux/amd64

Getting Started with Go

We'll set up a workspace and assemble a straightforward "Hi world" program that will basically print the exemplary "hi world" message. 

Of course the workspace index is set to $HOME/go, to make it, type: 

mkdir ~/go

Inside the workspace make another registry src/hi: 

mkdir -p ~/go/src/hello

In that registry make a document named hello.go with the accompanying substance: 

~/go/src/hello/hello.go

package main

import "fmt"

func main() {
    fmt.Printf("Hello, World\n")
}

You can study Go workspace index chain of command here . 

To assemble the document, explore to the ~/go/src/hi catalog and run the go form order: 

cd ~/go/src/hello
go build

The order above will fabricate an executable named hi. 

You can run the executable by basically executing the order underneath: 

./hello

The yield should look something like this: 

Hello, World

Conclusion

Since you have downloaded and introduced Go on your Ubuntu framework, you can begin building up your Go ventures. 

On the off chance that you hit an issue or have criticism, leave a remark beneath.




CFG