gobrew - 複数バージョンのGoも簡単に管理、切り替え
ここ最近熱くなっているGo界隈ですが、開発が熱心に行われているとどんどんバージョンアップしていきます。その度に若干動作が変わったりして最新版を追いかけるのも大変です。さらに1.1系、1.2系でライブラリがちゃんと動作するかを確認するのも面倒になるでしょう。 そこで便利なのがプログラミング言語のバージョン管理ツールです。renvやPyenv、rvmなどが有名なジャンルですね。gobrewはGo向けに作られたインストール&切り替えツールです。
gobrewの使い方
インストールは簡単で、curlまたはwgetでできます。
$ curl -L https://raw.github.com/grobins2/gobrew/master/tools/install.sh | sh
$ wget --no-check-certificate https://raw.github.com/grobins2/gobrew/master/tools/install.sh -O - | sh
インストールが終わったら、
export PATH="$HOME/.gobrew/bin:$PATH"
eval "$(gobrew init -)"
を .bash_profile なりに追加すれば準備完了です。
まず最初にヘルプを見てみます。
$ gobrew --help
version 0.0.2
Usage: gobrew <command> [<args>]
Some useful gobrew commands are:
install Install a version of go. example: gobrew install 1.1.2
uninstall Uninstall a version of Go.
use Specify which go version to use.
list List available versions of go. example: gobrew list
version Show the current Go version in use.
versions Display all versions of Go installed.
rehash Rehash gobrew shims (run this after installing executables)
workspace Run 'gobrew workspace set' from your workspace folder to set as $GOPATH.
See `gobrew help <command>' for information on a specific command.
For full documentation, see: https://github.com/grobins2/gobrew#readme
listサブコマンドを使うとオンライン上にあるバージョンをリストアップしてくれます。
$ gobrew list
:
1.0.3
1.1
1.1.1
1.1.2
1.1beta1
1.1beta2
1.1rc1
1.1rc2
1.1rc3
1.2
1.2.1
1.2rc1
1.2rc2
1.2rc3
1.2rc4
1.2rc5
ちょっとソートが変ですが、この中からバージョンを指定してインストールできます。
$ gobrew install 1.2.1
また、ワークスペースの変更もサポートしています。
楽しいGo言語生活に活かしてください!
gobrewはBashスクリプト製、MIT Licenseのオープンソース・ソフトウェアです。