# Installing Go (Golang) on Linux for Seamless Pentesting Tool Integration

Golang, also known as Go, has become a popular programming language for creating powerful tools, especially in areas like penetration testing. However, setting up Go on Linux Systems, particularly those without pre-installed Go, can be tricky. This guide simplifies the process, providing a straightforward way to configure Go on VPS running Debian-based Linux platforms. By following these steps, you'll seamlessly integrate Go into your system, unlocking a variety of pentesting tools developed in Go.

## Identify System Architecture

Note: Before proceeding with the installation of Golang on your system, it's crucial to verify your system architecture. You can do this by running either of the following commands in your terminal:

```bash
uname -a
# OR 
dpkg --print-architecture
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701784407318/1ca58467-1361-4cc8-8801-fe9a1c1c517b.png align="center")

These commands will provide information about your system's architecture, such as "amd64" or "arm64".

Once you've identified your system architecture, download the specific Golang package corresponding to your architecture from the official Golang download page [https://golang.org/dl/](https://golang.org/dl/). Choosing the correct package ensures a seamless installation process tailored to your system, enhancing the overall compatibility and performance of Golang on your machine.

## Download Go

Visit - [<mark>https://go.dev/dl/</mark>](https://go.dev/dl/)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701791695782/61abfceb-967f-4dee-90a3-36d1f19168fc.png align="center")

Download the latest Linux version, usually in the format "gox.xx.x.linux-amd64.tar.gz."

Copy the Link and In the terminal type wget &lt;copied link&gt;

`wget https://go.dev/dl/go1.21.4.linux-amd64.tar.gz`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701787186991/332c6a2b-b032-416e-ad25-8b3d39eeb428.png align="center")

**Access Your Downloads Folder:**

If you've downloaded a file from a web browser and need to navigate to the downloads folder, you can typically do this through the terminal using the `cd` (change directory) command.

`cd /path/to/your/downloads`

## Setup Go

**Extract Go Files:**

Execute the following command to extract the downloaded files:

```bash
sudo tar -C /usr/local/ -xzf go1.21.4.linux-amd64.tar.gz 
# Change filename accordingly which is downloaded
```

Note: To determine your system's current shell type, execute the following command:

```bash
echo $0
```

This command will display the currently running shell, such as "bash" or "zsh"

If your current shell is zsh, the configuration file will be different accordingly. Open your shell configuration file for editing using the following command:

```bash
# For bash:
nano ~/.bashrc

# For zsh:
nano ~/.zshrc
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701789091301/ebca0b13-b662-4528-9dfc-72b02245b491.png align="center")

Afterwards, append the following lines at the end of the file to set up the necessary environment variables.

```bash
export GOPATH=$HOME/go-workspace
export GOROOT=/usr/local/go
PATH=$PATH:$GOROOT/bin/:$GOPATH/bin
```

To save your changes, press CTRL+X, followed by Y.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701790306454/0ef4eecd-6191-4615-8bf1-2a8a01863ced.png align="center")

Restart the Shell:

```bash
exec $SHELL
```

## Verify Your Go Installation

```bash
go version
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701789293889/5682c7c5-9a57-43af-9d5e-082b69492210.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701791987994/ce340d71-8e0a-44f8-8502-9d6735c40c50.gif align="center")

By default, Go does not enforce a single, centralized workspace for all users on a system. Each user typically maintains their own workspace for Go development. The location of this workspace is determined by the `GOPATH` environment variable.

The root user, being a different user, would need to set up their Go workspace separately if they intend to work with Go projects.

## Installing via Automated Script

If you prefer a hassle-free approach, I've crafted an automated shell script that streamlines the entire process. This script not only downloads the latest Go package but also takes care of extraction and sets up the necessary environment variables based on the detected shell.

No need to manually intervene or configure settings – simply run the script, and it will handle everything for you, ensuring a swift and seamless Go installation experience.

```bash
wget https://raw.githubusercontent.com/mr-rizwan-syed/chomtesh/main/goinstaller.sh
chmod +x goinstaller.sh
./goinstaller.sh
```

## Uninstalling Go

If the Go is already installed on your system, and for some reason, you want to uninstall that, you can follow the below steps.

```bash
rm -rf $(which go)
# OR
sudo apt-get remove golang-go
sudo apt-get remove --auto-remove golang-go
```
