LoginSignup
6
5

gvmでGoをインストールする時はバイナリからがオススメ

Last updated at Posted at 2017-05-10

gvmとは

https://github.com/moovweb/gvm
Goのバージョン管理ツール。
nodeでいうnodebrewやnvmみたいなものです。
ubuntuでaptでGoをインストールすると少し古いバージョンのものが入るので、バージョンを指定してインストールしたい時に便利です。

インストール

環境

Ubuntu 16.04LTS

依存ライブラリ

sudo apt install curl git mercurial make binutils bison gcc build-essential

gvmのインストール

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

使い方

Usage: gvm install [version] [options]
    -s,  --source=SOURCE      Install Go from specified source.
    -n,  --name=NAME          Override the default name for this version.
    -pb, --with-protobuf      Install Go protocol buffers.
    -b,  --with-build-tools   Install package build tools.
    -B,  --binary             Only install from binary.
         --prefer-binary      Attempt a binary install, falling back to source.
    -h,  --help               Display this message.

ソースからインストール

gvm install go1.4

注意点

バージョン1.5以上をインストールする際には、Goの1.4が必要になります。

以下、1.5以上のインストール方法(公式より)

gvm install go1.4 -B
gvm use 1.4
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.5

バイナリからインストール

上記の方法でソースからインストールする場合、1.4のインストールやスペックの低いPCだとコンパイルに時間がかかったりと色々と面倒なので、バイナリからインストールします。

gvm install go1.8 -B

-B のオプションを付けるだけです。

6
5
1

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
6
5