Posts Install Golang on Ubuntu Server
Post
Cancel

Install Golang on Ubuntu Server

Purpose of this documentation is to install Golang on Ubuntu Server. Follow these instructions step by step.

Let’s Begin

  • Define the Go version to install
1
GO_VERSION="1.24.4"
  • Define the architecture (amd64, arm64, etc.)
1
ARCH="$(dpkg --print-architecture)"
  • Define the installation directory
1
INSTALL_DIR="/usr/local"
  • Download the Go binary using curl
1
curl -LO "https://golang.org/dl/go$GO_VERSION.linux-$ARCH.tar.gz"
  • Extract the downloaded compressed file
1
tar -C "$INSTALL_DIR" -xzf "go$GO_VERSION.linux-$ARCH.tar.gz"
  • Link to /usr/bin/
1
sudo ln -s $INSTALL_DIR/go/bin/go /usr/bin/go
  • Remove the downloaded compressed file
1
rm "go$GO_VERSION.linux-$ARCH.tar.gz"
  • Add Golang to environment
1
2
3
4
5
# Go environment
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$GOROOT/bin:$GOBIN:$PATH
  • Verify the installation
1
go version