Install & Run

circle-exclamation

Install

Manually

Officially, Go docs tells to manually download the latest version and install it.

wget https://go.dev/dl/go1.xx.x.linux-amd64.tar.gz
sudo rm -rf /opt/go && sudo tar -C /opt -xzf go1.*.linux-amd64.tar.gz

Add this env to .bashrc.

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

Version manager

There is a version managerarrow-up-right kind of like python pyenv.

It automatically adds the Path variables to .bashrc and installs the latest Go version.

wget -qO- https://git.io/g-install | sh -s

Other commands:

# Download and set version to latest
g install latest

# Download and set to <version>
g install <version>

# List installed versions
g list

# List all versions
g list-all

# Remove all versions, except the current used one
g prune

Compile & Run

Run uncompiled

Run an uncompiled file.go file with:

Compile

circle-exclamation

Run compiled

In Windows the compiled will be a .exe file, whether in Linux or Mac it will be a executable file.

Last updated