Skip to content

Instantly share code, notes, and snippets.

@erycamel
Forked from renevo/go-wsl.md
Created January 21, 2024 11:42
Show Gist options
  • Save erycamel/ba0fab720a64ae49396ec19713047850 to your computer and use it in GitHub Desktop.
Save erycamel/ba0fab720a64ae49396ec19713047850 to your computer and use it in GitHub Desktop.
Easily update/install Go in wsl

Updating/Installing Go in WSL

Remove

Removes older versions

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

Install

Change version as applicable

VERSION=1.11
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/local

Add Go Environment

Open up ~/.bashrc and update/add the following near the bottom (replace with correct go version)

# configure go-1.11
export GOROOT=/usr/local/go-1.11
export GOPATH=$HOME/projects/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
export PATH=$PATH:$HOME/projects/go/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment