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 want to install GoLang on WSL/WSL2 and setup your development environment, please follow these steps
Check Latest Go Version
You can check latest Go Version for any OS like: Linux, macOS or Windows at https://go.dev/dl/
Install Go
At the time of writing this blog, the most recent LTS version of Go is 1.18.3.
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
Edit .bashrc file
You have to edit .bashrc file before making further changes, you can follow below steps to open .bashrc file
cd ~
explorer.exe .
Open .bashrc file and add following lines at the bottom and save the file.
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Refresh your terminal using **bash **command
Check Go Version
go version
Make sure it returns the same version that you installed.
Top comments (18)
Thanks this helped. I had some minor differences in steps I took, which I will list below:
.zshrc
insteadsource ~/.zshrc
instead of spawning a new shell.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
The same for me!
Thanks, this works for bashrc also.
You can use
nano .bashrc
instead of File Explorer.Thanks for this, worked perfectly 👌
You can also use $ code ~/.bashrc instead of explorer.exe .
even simpler use neovim or vi or vim
Perfect, thanks man
very helpful, thanks
Be sure to always go to go.dev/dl/ to check the latest go version when downloading the
.tar.gz
!Hell yeah! Nice and easy, thanks!
Just used it - worked great. Thanks!
workedp amazing