> For the complete documentation index, see [llms.txt](https://docs.acecloud.ai/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acecloud.ai/knowledge-base/tutorials/how-to-install-go-on-ubuntu-20.04.md).

# How to install Go on Ubuntu 20.04?

{% embed url="<https://youtu.be/KXu-jEH9yr8>" %}

### Overview  <a href="#howtoinstallgoonubuntu20.04-overview" id="howtoinstallgoonubuntu20.04-overview"></a>

Go, also known as Golang, is an open-source language designed for efficient and reliable system programming, making it a popular choice for developing high performance software applications. Go's integrated concurrency support, which enables programmers to create effective and scalable concurrent programmes without the use of other libraries or frameworks, is one of its core characteristics. Overall, it is a versatile and powerful language that is well suited for building a variety of applications, including network services, web applications, and more.

Here is a step-by-step tutorial on how to install Go on Ubuntu 20.04 using source code.

### Prerequisites <a href="#howtoinstallgoonubuntu20.04-prerequisites" id="howtoinstallgoonubuntu20.04-prerequisites"></a>

There are certain prerequisites that need to be met before you begin.&#x20;

* Ubuntu 20.04 LTS configured on your system.
* Non-root sudo user privileges.

### Get Started <a href="#howtoinstallgoonubuntu20.04-getstarted" id="howtoinstallgoonubuntu20.04-getstarted"></a>

**Step 1: Installation**

* Check to see if you are in the home directory:

```
cd ~
```

The most recent version of Go is go1.20.1. Visit [Go's official documentation of featured versions.](https://go.dev/dl/), copy the URL of the file that ends in "linux-amd64.tar.gz" and ensure to replace the URL in the command.&#x20;

* Execute curl to fetch the tarball:&#x20;

```
curl -OL https://go.dev/dl/go1.20.1.linux-amd64.tar.gz
```

{% hint style="info" %}
**Note:** Since this link was copied from the Go website and will reroute here in the home directory before the file download begins:
{% endhint %}

* The -O flag guarantees that this outputs to a file,
* The L flag prompts HTTPS redirects.

**Note:** Ensure to replace the URL in the command with the one you obtained from [Go's official documentation of featured versions. ](https://go.dev/dl/)

<img src="http://customer.acecloudhosting.com/index.php?rp=/images/kb/988_curl.png" alt="" height="125" width="1523">

* Use the sha256sum command with the filename as a parameter to check the file's integrity after it is downloaded:

```
sha256sum go1.20.1.linux-amd64.tar.gz
```

The output will display the SHA256 checksum of the tarball.

<img src="http://customer.acecloudhosting.com/index.php?rp=/images/kb/989_checksum.png" alt="" height="50" width="1526">

{% hint style="info" %}
**Note:** You can verify the checksum by matching it with the one provided on the downloads page. If they match, then this step is accomplished.&#x20;
{% endhint %}

* Retrieve the tarball:

```
sudo tar -C /usr/local -xvf go1.20.1.linux-amd64.tar.gz
```

The parameters of the above command are:

* The -C instructs tar to change to the specified directory before performing additional tasks.
* Go should be installed in the /usr/local/ directory.
* The x flag tells tar to extract.
* The v flag instructs tar to produce verbose output containing a list of extracted files.&#x20;
* The f flag tells tar to output a filename.

**Step 2: Path Setup**

Set Go's root value first so it knows where to seek for its files. This can be accomplished by altering the commands listed in the `.profile` file, which is executed by the system upon each log-in.

* Open the `.profile` file located in your user's home directory:

```
sudo nano ~/.profile
```

* At the end of the `.profile` file, add the Go binary path:

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

Press CTRL + X to save and close the file.&#x20;

* Once the file is closed, update your profile:&#x20;

```
source ~/.profile
```

* Print the version of go to verify if you can run the Go commands:

```
go version
```

The output will display the version of Go that you just installed on your system using the tarball:

<img src="http://customer.acecloudhosting.com/index.php?rp=/images/kb/990_version.png" alt="" height="52" width="1523">

**Step 3: Testing**

Now, that the installation of Go and its path setup have been successful, you can begin testing the functioning of Go.&#x20;

* Make a new directory for Go to build its files:

```
mkdir file
```

{% hint style="info" %}
**Note:** Here, we have created a directory with the name "*file"*. You can name your directory according to your project.&#x20;
{% endhint %}

* Enter into the directory:

```
cd file
```

* Open the nano text editor:

```
nano file.go
```

* Write the following 'Hello, World!' program in the editor:

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

* Compile and run your code with the *go run* command:

```
go run file.go
```

The output will display as:

<img src="http://customer.acecloudhosting.com/index.php?rp=/images/kb/991_file.png" alt="" height="52" width="1525">

### Conclusion <a href="#howtoinstallgoonubuntu20.04-conclusion" id="howtoinstallgoonubuntu20.04-conclusion"></a>

You now have a system to utilize for Go programming after downloading, installing, and establishing its paths.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.acecloud.ai/knowledge-base/tutorials/how-to-install-go-on-ubuntu-20.04.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
