If you need to install Golang on WSL under Windows 10 or higher, you can follow these few steps.
First remove any old versions lying around
sudo rm -rf /usr/local/go* && sudo rm -rf /usr/local/go
Determine the latest Go version
Go to https://golang.org/dl/ and find out what the latest version is. At the time of writing this, Go is on version 1.16.
Make sure to replace
1.16 below with the updated version as required.
tar -xvf go$VERSION.$OS-$ARCH.tar.gz
mv go go-$VERSION
sudo mv go-$VERSION /usr/local
Add Go to your environment profile
~/.bashrc and add the following. Remember to update the
1.16 to the version you installed.
You will now be able to run Go by typing
go in the WSL terminal.