DEV Community

How to Install Golang on WSL/WSL2

Mrityunjaya Prajapati on June 13, 2022

One of the best feature that Windows 10 or 11 Pro support is WSL or WSL2, using this you can run any Linux OS like a windows application. If you w...
Collapse
 
j3rg profile image
Jorgen Ordonez •

Thanks this helped. I had some minor differences in steps I took, which I will list below:

  • I use zsh so I edited .zshrc instead
  • Then after I reload the rc file using source ~/.zshrc instead of spawning a new shell.
Collapse
 
ikesalmonson profile image
Luiz Henrique F Salmonson •

Thank you. Update for current version and zsh user commands:
wget https://dl.google.com/go/go1.21.3.linux-amd64.tar.gz
sudo tar -xvf go1.21.3.linux-amd64.tar.gz
sudo mv go /usr/local
echo "export GOROOT=/usr/local/go" >> ~/.zshrc
echo "export GOPATH=\$HOME/go" >> ~/.zshrc
echo "export PATH=\$GOPATH/bin:\$GOROOT/bin:\$PATH" >> ~/.zshrc
source ~/.zshrc

Collapse
 
it0dan profile image
D.aȠ •

The same for me!

Collapse
 
talk2onyx profile image
Olaleye Obidiya •

Thanks, this works for bashrc also.

wget https://dl.google.com/go/go1.23.0.linux-amd64.tar.gz
sudo tar -xvf go1.23.0.linux-amd64.tar.gz
sudo mv go /usr/local
echo "export GOROOT=/usr/local/go" >> ~/.bashrc
echo "export GOPATH=\$HOME/go" >> ~/.bashrc
echo "export PATH=\$GOPATH/bin:\$GOROOT/bin:\$PATH" >> ~/.bashrc
source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode
Collapse
 
louiemartin profile image
LouieMartin •

You can use nano .bashrc instead of File Explorer.

Collapse
 
just_nodes profile image
Justin •

Thanks for this, worked perfectly 👌

You can also use $ code ~/.bashrc instead of explorer.exe .

Collapse
 
ujjaval999 profile image
Parmar Ujjaval •

even simpler use neovim or vi or vim

Collapse
 
nathankurz91 profile image
Nathan Kurz •

Hell yeah! Nice and easy, thanks!

Collapse
 
extremelysunnyyk profile image
Chia Yong Kang •

workedp amazing

Collapse
 
asross311 profile image
Andrew Ross •

Perfect, thanks man

Collapse
 
fricardi profile image
FRicardi •

Just used it - worked great. Thanks!

Collapse
 
nurudeeen profile image
Nurudeen Rabiu Alabi •

very helpful, thanks

Collapse
 
mogueno profile image
Mogueno •

Be sure to always go to go.dev/dl/ to check the latest go version when downloading the .tar.gz!

Collapse
 
sabrodigan profile image
Stephen Brodigan •

What an absolutely perfect solution to install Go, thank you!

Collapse
 
praveen_sharma_e830cb06a0 profile image
Praveen Sharma •

Created an acc on this site , Just to say you thank you

Thank You , My Friend

Collapse
 
rpetz profile image
Robert Petz •

Thank you - this actually worked for me!

Straight to the point and effective

Collapse
 
chinwendu20 profile image
Maureen Ononiwu •

Thank you so so so much!!

Collapse
 
it0dan profile image
D.aȠ •

Thanks! Almost everything works fine!

Collapse
 
justin_morales_225c97a732 profile image
Justin Morales •

Good deal

Can We connect to discuss?

I'm interested in exploring a potential business collaboration with you, as I believe our combined efforts could be mutually beneficial.

Please let me know if you'd be open to discussing this further.

Collapse
 
levpa profile image
Lev Pa •

not immutable, prone to errors...