DEV Community

Cover image for WSL Install Go
karleeov
karleeov

Posted on

25 1

WSL Install Go

Hey, do you want to run Linux on your Windows like a boss? Well, you can with WSL or WSL2, which are awesome features of Windows 10 or 11 Pro. And guess what? You can also install GoLang on your WSL/WSL2 and code like a pro. Here’s how:

First, you need to find out the latest and greatest version of Go for your OS. Whether you use Linux, macOS or Windows, you can check it out at https://go.dev/dl/

Next, you need to download and install Go on your WSL/WSL2. At the time of writing this blog, the coolest version of Go is 1.18.3.

To get it, just type these commands in your terminal:

wget https://dl.google.com/go/go1.18.3.linux-amd64.tar.gz
sudo tar -xvf go1.18.3.linux-amd64.tar.gz
sudo mv go /usr/local

Now, you need to tell your WSL/WSL2 where to find Go and where to store your Go projects. To do that, you need to edit a file called .bashrc, which is like a magic spell book for your terminal.

To open it, just type these commands in your terminal:

cd ~
explorer.exe .

Then, open the .bashrc file and add these lines at the end of it:

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Save the file and close it. Then, refresh your terminal by typing this command:

bash

Finally, you can check if Go is installed correctly by typing this command:

go version

If you see something like go version go1.18.3 linux/amd64, then congratulations! You have successfully installed Go on your WSL/WSL2 and you are ready to rock! 🎸

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

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

Okay