Install Go go1.19.3  Language WSL.2 - Ubuntu 22.04 LTS

Install Go go1.19.3 Language WSL.2 - Ubuntu 22.04 LTS

Install Go 1.19.3 Language WSL.2 - Ubuntu 22.04 LTS

Table of contents

No heading

No headings in the article.

In this article i will guide you how to install Go 1.9 version on WSL 2 i'm using Ubuntu 22.04 LTS on windows 10. S

➜  ~ wsl.exe --list
Windows Subsystem for Linux Distributions:
Ubuntu-22.04

1- Update Ubuntu Packages .

➜ sudo apt-get update
➜ sudo apt-get -y upgrade

2- Download latest version available . officialdownload page.

➜ wget https://go.dev/dl/go1.19.3.linux-amd64.tar.gz
➜ sudo tar -xvf go1.19.3.linux-amd64.tar.gz
➜ sudo mv go /usr/local

3- Setup Go Environment .

Commonly you need to set 3 environment variables as GOROOT, GOPATH and PATH.

GOROOT is the location where Go package is installed on your system.

export GOROOT=/usr/local/go

GOPATH is the location of your work directory.

export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Enviroment variables are set only for current session so to make it permanent add above commands in ~/.profile file.

4- Verify Golang Installation.

 ➜ go version
go version go1.19.3  linux/amd64

Optional : Print all go environment variables .

➜ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/sameh/.cache/go-build"
GOENV="/home/sameh/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/sameh/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/sameh/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"

Thanks a lot .