Sunday, December 3, 2023
HomeSoftware EngineeringThe way to Set up Golang on WSL/WSL2

The way to Set up Golang on WSL/WSL2


If it’s essential set up Golang on WSL underneath Home windows 10 or larger, you possibly can comply with these few steps.

First take away any outdated variations mendacity round

sudo rm -rf /usr/native/go* && sudo rm -rf /usr/native/go

Decide the most recent Go model

Go to https://golang.org/dl/ and discover out what the most recent model is. On the time of penning this, Go is on model 1.16.

Set up Go

Be certain that to interchange 1.16 under with the up to date model as required.

VERSION=1.16
OS=linux
ARCH=amd64

cd $HOME
wget https://storage.googleapis.com/golang/go$VERSION.$OS-$ARCH.tar.gz
tar -xvf go$VERSION.$OS-$ARCH.tar.gz
mv go go-$VERSION
sudo mv go-$VERSION /usr/native

Add Go to your atmosphere profile

Open ~/.bashrc and add the next. Keep in mind to replace the 1.16 to the model you put in.

export GOROOT=/usr/native/go-1.16
export GOPATH=$HOME/tasks/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
export PATH=$PATH:$HOME/tasks/go/bin

You’ll now have the ability to run Go by typing go within the WSL terminal.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments