VOOZH about

URL: https://www.tecmint.com/install-go-in-ubuntu/

โ‡ฑ How to Install Go in Ubuntu 20.04


Skip to content

Go is a popular programming language created by Google. The first release was on November 10, 2009, and version 1.0 was released in 2012. It is a pretty new language compared to languages like Java, Python, C, C++, etc.. which has been in the market for more than 15 plus years.

Go was Implemented with Assembly language (GC); C++ (gccgo) and Go. In many places, you may see people refer to go as golang and that is because of its domain name, golang.org, but the proper name is Go. Go is cross-platform, it can be installed on Linux, Windows, and macOS.

Features of Go Programming

Following are some of the core features of Go.

  • Statically type and compiled programming language.
  • Concurrency support and Garbage collection.
  • Strong library and toolset.
  • Multiprocessing and High-performance networking.
  • Known for readability and usability (Like Python).

In this article, you will learn how to install and set up Go Programming Language in Ubuntu 20.04.

Installing Go Language in Ubuntu

We will be installing the latest version of Go which is 1.15.5. To download the latest version, go to the official download page and grab the tarball or use the following wget command to download it on the terminal.

$ sudo wget https://golang.org/dl/go1.15.5.linux-amd64.tar.gz

Next, extract the tarball to /usr/local directory.

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

Add the go binary path to .bashrc file /etc/profile (for a system-wide installation).

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

After adding the PATH environment variable, you need to apply changes immediately by running the following command.

$ source ~/.bashrc

Now verify the installation by simply running the go version in the terminal.

$ go version

You can also install go from the snap store too.

$ sudo snap install --classic --channel=1.15/stable go 

Letโ€™s run our traditional hello world program. Save the file with .go extension.

$ cat > hello-world.go

package main

import "fmt"

func main() {
 fmt.Println("Hello, World!")
}

To run the program type go run <file-name> from the terminal.

$ go run hello-world.go
๐Ÿ‘ Run Go Programe in Linux
Run Go Program in Linux

Remove Go Language in Ubuntu

To remove Go from the system remove the directory where the go tarball is extracted. In this case, go is extracted to /usr/local/go. Also, remove the entry from ~/.bashrc or ~/.bash_profile depending upon where you added the export path.

$ sudo rm -rf /usr/local/go
$ sudo nano ~/.bashrc # remove the entry from $PATH
$ source ~/.bashrc

Thatโ€™s it for this article. Now you have, Go up and running to play with it.

If this article helped, share it with someone on your team.
TecMint Weekly Newsletter
Get the Learn Linux 7 Days Crash Course free when you join 34,000+ Linux professionals reading every Thursday.
Check your email for a magic link to get started.
Something went wrong. Please try again.
โ˜•
TecMint has been free for 14 years. Help keep it that way.
Google AI Overviews and tools like ChatGPT have cut into search traffic for independent tech sites like TecMint. Running this site costs over $2,000 every month for hosting, infrastructure, and paying authors to keep the content accurate and tested.

If this article helped you solve a problem, consider buying a coffee. It helps keep TecMint free, supports the authors, and keeps the project going.
โ˜• Buy Me a Coffee
Karthick
A passionate software engineer who loves to explore new technologies. He is a public speaker and loves writing about technology, especially about Linux and open source.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

7 Comments

Leave a Reply
  1. A very helpful article for beginners like me who trying to understand Go programmingโ€ฆ

    Reply
    • @ahmad

      Glad it helped you :)

      Reply
  2. Seriously?

    $ sudo apt install golang
    

    You donโ€™t need a whole article for that.

    Reply
    • @Matt

      Thanks for your feedback.

      Agreed with your point. using a package manager is an easy way to install, but this method is suitable for other distributions like RHEL and ARCH too.

      Reply
      • Ahh fair play, I keep forgetting about other distros ^^

        Matt

        Reply
  3. You can do that, or you can just do FROM go:latest and then docker run it. Much less hassle and less garbage in your system.

    Reply
    • @Turbo unicorn

      Thanks for sharing your suggestion.

      Reply

Got Something to Say? Join the Discussion... Cancel reply

Free Course
Get a free Linux course before you go.
Subscribe to TecMint Weekly and get the Learn Linux 7 Days Crash Course free. Read by 34,000+ Linux professionals every Thursday.
Check your email for a magic link to get started.