How to install and run the Go programming language on Ubuntu – Golang

Go or Golang is a free and open source concurrent, functional, imperative, object-oriented programming language for Linux, macOS, Windows and BSD, created by Google. Benefits include memory safety, garbage collection, and structured typing. Famous projects written in Go include Docker and Kubernetes, Google’s download server, hootsuite and Crowdfire. Emacs, Vim, VSCode, Atom, Eclipse, Sublime, IntelliJ support go language.

Install the Go programming language on Ubuntu.

Download the Go binary.

Go to the go language download page above and download the latest Linux version. Here, the downloaded file name “go1.14.2.linux-amd64.tar.gz“Right click on this file and select Extract here option. you are”go“folder.

How to install and run the Go programming language on Ubuntu – Golang

Then open the file manager in root mode. Use this command if you are using the nautilus file manager.

sudo -E nautilus

If the file manager is thunar (xfce),

sudo -E thunar

Then copy the go directory and / usr / local folder.

How to install and run the Go programming language on Ubuntu – Golang

[Or]

You can also do all this by running the following command in the terminal app (Ctrl + Alt + T)

wget -c https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local

Here is the current version 1.14.2 The download URL for the Linux version is https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz You can change this URL based on the download link. You can check it from the binary download link above.

Recommended reading: how to install electterm on Ubuntu-terminal, file manager, ssh, sftp client

How to install and run the Go programming language on Ubuntu – Golang

Then in addition go The folder path to the $ PATH environment variable. At the terminal

export PATH=$PATH:/usr/local/go/bin
source ~/.profile

Reboot the system and confirm the installation

go version

If an error occurs. Do this again.

export PATH=$PATH:/usr/local/go/bin
source ~/.profile

Run the Go Hello World program.

create go / src / connectwww A folder within the user name folder. Or run this command to create it.

mkdir -p ~/go/src/connectwww

How to install and run the Go programming language on Ubuntu – Golang

Created connectwww Create a file called a folderconnectwww.go

How to install and run the Go programming language on Ubuntu – Golang

How to install and run the Go programming language on Ubuntu – Golang

Open that file, write the following code and save it.

package main

import (
"fmt"
)

func main() {
fmt.Println("Hello, CONNECTwww.com")
}

How to install and run the Go programming language on Ubuntu – Golang

Next move go / src / connectwww At the terminal.

cd go/src/connectwww

Then build the program using the following command:

go build

Then run

./connectwww

How to install and run the Go programming language on Ubuntu – Golang

It’s a sequel.

.

Sidebar