With Go 1.18 just out and in GA, I was curious to give Go "a go" (pun intended) and play around a bit with Generics - a highly anticipated feature in Go! but first I had to install it. I chose to go with WSL 2 and use Ubuntu for my new playground but I also wanted to install everything from the command line. Let's go!
Is there a video?
Funny you ask? I've also recorded a 4min video that takes you through the process if you are a visual person. Check it out:
First we want to remove old versions of Go. Run the following command in WSL Ubuntu:
sudo rm -rf /usr/local/go* && sudo rm -rf /usr/local/go
Then we want to download the latest version (currently 1.18). The commands for this are:
wget https://go.dev/dl/go1.18.linux-amd64.tar.gz tar -xvf go1.18.linux-amd64.tar.gz mv go go-1.18 sudo mv go-1.18 /usr/local
Next we need to add Go to our environment profile so that it can get picked up by our command line. Open
~/.bashrc with VS Code or your favorite editor:
Update the settings are per below:
export GOROOT=/usr/local/go-1.18 export GOPATH=$HOME/go export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Restart your command line/terminal and verify that the latest version has been installed correctly by typing
Job done! Happy coding with Go(lang)