DEV Community

ShivamS
ShivamS

Posted on

2 1 1

Installing Golang on Windows WSL/WSL2

Official Go documentation might not provide the steps to install Go on WSL/WSL2. If you want to install GoLang and set up the development environment, follow these steps:

  • Go to https://go.dev/dl/ and check the latest Go version.
  • Open your terminal and use the command to download the specific version.
    Note: Replace go1.24.0.linux-amd64.tar.gz with the latest version.
    wget https://dl.google.com/go/go1.24.0.linux-amd64.tar.gz

  • Unzip:
    sudo tar -xvf go1.24.0.linux-amd64.tar.gz

  • Move to the correct path.
    sudo mv go /usr/local

  • Edit the .bashrc file:

echo "export GOROOT=/usr/local/go" >> ~/.bashrc
echo "export GOPATH=\$HOME/go" >> ~/.bashrc
echo "export PATH=\$GOPATH/bin:\$GOROOT/bin:\$PATH" >> ~/.bashrc
Enter fullscreen mode Exit fullscreen mode
  • Refresh the terminal:
    source ~/.bashrc

  • Verify the Go version.
    go version

Happy Learning!!

Top comments (2)

Collapse
 
shricodev profile image
Shrijal Acharya

Why not use a package manager?

Collapse
 
sonishivam10 profile image
ShivamS

Yeah, agree - using a package manager is the easiest and simplest way. But it might have an outdated version available (if using apt). So, manual installation is better if you want the latest version as soon as it’s released, downloading it from go.dev is the best option.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay