0
0

More than 1 year has passed since last update.

ubuntuに最新のgolangをインストールする

Posted at

環境

Ubuntu 16.04.7

既にgoが入っている場合は、アンインストール

ubuntuのデフォルトでインストールできるバージョンは古いので、
もし入れてしまった場合は下記でアンインストールしてください

$ sudo apt-get remove golang-go
$ sudo apt-get remove --auto-remove golang-go
$ sudo apt-get purge golang*

goの最新のバージョンを確認

・今回はubuntuに入れるので、「Linux」の「x86-64」から選択
https://go.dev/dl/

作業スペースに移動して圧縮ファイルをダウンロードし、「/usr/local」に解凍します

$ wget https://go.dev/dl/go1.17.6.linux-amd64.tar.gz
$ tar -C /usr/local -xzf go1.17.6.linux-amd64.tar.gz

GO のbinの場所を環境変数に追加

$ export PATH=$PATH:/usr/local/go/bin

最新のバージョンになっていればOKです

$ go version

永続的に環境変数を設定

再度puttyなどを再起動するとPATHに設定したgoのpathがリセットされるので、
永続的に登録する場合はホームディレクトリーの「.profile」の最後に設定を追加してください
「PATH=$PATH:/usr/local/go/bin」

$ cd /home/{userName}
$ vi .profile
0
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
0
0