DEV Community

Cover image for Install Golang On Ubuntu
Zahid Ahmed
Zahid Ahmed

Posted on

Install Golang On Ubuntu

This guide walks through a clean, system-wide installation of Go using the official binary, following industry best practices.

πŸ“‚ Step 1: Download the Latest Go Binary

wget https://go.dev/dl/go1.25.6.linux-amd64.tar.gz
Enter fullscreen mode Exit fullscreen mode

πŸ“‚ Step 2: Install Go System-Wide

tar -C /usr/local -xzf go1.25.6.linux-amd64.tar.gz
Enter fullscreen mode Exit fullscreen mode

πŸ“‚ Step 3: Configure Environment Variables (Global Setup)

cat <<EOF >/etc/profile.d/go.sh
export GOROOT=/usr/local/go
export GOPATH=/opt/go
export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin
EOF
Enter fullscreen mode Exit fullscreen mode
chmod +x /etc/profile.d/go.sh
Enter fullscreen mode Exit fullscreen mode

πŸ“‚ Step 4: Create GOPATH Directory Structure

mkdir -p /opt/go/{bin,src,pkg}
Enter fullscreen mode Exit fullscreen mode

πŸ“‚ Step 5: Reload Environment Variables

source /etc/profile
Enter fullscreen mode Exit fullscreen mode

πŸ“‚ Step 6: Verify the Installation

go version
Enter fullscreen mode Exit fullscreen mode

Happy coding with Go πŸš€

Top comments (0)