LoginSignup
1
0

More than 1 year has passed since last update.

WSL2でUbuntu(20.04.2LTS)で最新のGolangをaptでインストールする

Last updated at Posted at 2021-06-30

はじめに

こんにちは。先ほど1年間無料のネット回線として契約してたRakuten UN-LIMITを解約しました :pray:
テレワークでとっても便利でしたが、都内から川崎市に引っ越してからパートナー回線しかつながらなくてほったらかししてました。

パートナー回線だと付き5GBで制限掛かるので使い物になりませんでした。

エリア内のはずなのに :thinking:

さて、今回はGolangを始めようと思い立ち、インストールしていこうと思います!
インストール方法はいろいろあると思いますが、aptで入れていこうと思います。

WSL2でUbuntu(20.04.2LTS)で最新のGolangをaptでインストールする

公式GitHubのWikiを参考に進めていきます :pray:

1. リポジトリ追加

最新バージョンが欲しいのでPPAの追加します。
Enterキー押してと言われると思うので押してください:pray:

$ sudo add-apt-repository ppa:longsleep/golang-backports

 Golang 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15 and 1.16 PPA for Ubuntu
 More info: https://launchpad.net/~longsleep/+archive/ubuntu/golang-backports
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 https://cli-assets.heroku.com/apt ./ InRelease
Get:2 http://ppa.launchpad.net/longsleep/golang-backports/ubuntu focal InRelease [17.5 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:4 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease
Hit:5 http://archive.ubuntu.com/ubuntu focal InRelease
Get:6 http://ppa.launchpad.net/longsleep/golang-backports/ubuntu focal/main amd64 Packages [2512 B]
Get:7 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:8 http://ppa.launchpad.net/longsleep/golang-backports/ubuntu focal/main Translation-en [1568 B]
Get:9 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1077 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [825 kB]
Fetched 2252 kB in 7s (309 kB/s)
Reading package lists... Done

2. おなじみのapt update

$ sudo apt update

3. インストール

golang-goはデフォルトで最新バージョンをインストールするので指定は不要 :ok_hand:

$ sudo apt install -y golang-go

4. バージョン確認

インストール完了しました!

$ go version

go version go1.16.5 linux/amd64

おわりに

意外と簡単にインストールできました:v:
それでは!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0