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! 🎸

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook