[Go] Procedure for installing Go on WSL2

Install Go on WSL2

I used Go installed on Windows so far, but I want to develop with WSL2 anyway, so I will install Go on WSL2

Execution environment

OS is ** Windows 10 Pro 64bit ** (version 2004 OS build 19041.572) ** WSL2 ** and OS ** Ubuntu-20.04 **

1. Download the installer

First, open Download and install --The Go Programming Language, select "Linux", and download the installer for Linux.

FireShot Capture 139 - Download and install - The Go Programming Language - golang.org.png

Move the installer downloaded at this time (go1.15.3.linux-amd64.tar.gz in the example) to a place that is easy for you to understand.

2. Launch WSL

Then open a command prompt or Windows terminal and run the wsl command to launch WSL

Microsoft Windows [Version 10.0.19041.572]
(c) 2020 Microsoft Corporation. All rights reserved.

C:\Users\sola>wsl
root@sola-pc:/mnt/c/Users/sola#

3. Execute the command described on the official website

I don't think there is, but ** If Go is installed in advance, please uninstall it **

First, expand to / usr / local with the following command

tar -C /usr/local -xzf go1.15.3.linux-amd64.tar.gz

4. After moving to the root, launch Explorer

After finishing, move to the route and launch Explorer there

root@sola-pc:/mnt/c/Users/sola# cd ~
root@sola-pc:~# explorer.exe .
root@sola-pc:~#

ʻExplorer.exe .` will launch the following explorer

スクリーンショット 2020-10-21 132322.jpg

(* I think that there are differences in files etc. depending on the environment, so please look at the image that a directory like this is opened to the last)

5. Setting environment variables

Open .bashrc with a text editor, add the following line and save.

.bashrc


export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

After that, restart the command prompt or terminal and start WSL again.

6. Make sure Go is installed

After launching with the wsl command, make sure that it is installed with the go version.

Microsoft Windows [Version 10.0.19041.572]
(c) 2020 Microsoft Corporation. All rights reserved.

C:\Users\sola>wsl
root@sola-pc:/mnt/c/Users/sola# go version
go version go1.15.3 linux/amd64
root@sola-pc:/mnt/c/Users/sola#

Reference URL

Recommended Posts

[Go] Procedure for installing Go on WSL2
Procedure for installing Xenomai on RaspberryPi 3 model B + Part 1
Talk about installing CUDA on WSL2
Notes for installing Sublime Text on Ubuntu
[Note] Procedures for installing Ubuntu on Windows 10
Installing TensorFlow on Windows Easy for Python beginners
Install python on WSL
Linux (WSL) on Windows
Notes on installing PycURL
Installing pandas on python2.6
Instructions for installing CUDA 7.5 on Mac (El Capitan) + Homebrew
Procedure for building a CDK environment on Windows (Python)
Procedure for creating a Line Bot on AWS Lambda
Installing pyenv on ubuntu 16.04
Offline installation procedure for openpyxl
Notes on installing dlib on mac
F2py on Miniconda for Windows
Notes on installing Python on Mac
wsl Install PostgreSQL on Ubuntu 18.04
Notes on installing pipenv on Mac
Install Docker on WSL Ubuntu 18.04
Notes on installing Anaconda 3 on Windows
Linux environment construction (on WSL environment)
Notes on installing Python on CentOS
Use Linux on Windows 10 (WSL2)
About the procedure for linking Visual Studio Code for Windows and WSL