LoginSignup
35
31

More than 5 years have passed since last update.

Go言語をyumで入れる

Last updated at Posted at 2016-03-21

公式ページのGetting Startedに書いてあるのはアーカイブをダウンロードして展開する方法ですが、epelリポジトリを追加することでyumでインストールすることができます。ただし、現時点で配布されているバージョンは1.5.1です。

Golangのリリース履歴
Go 1.6 (February 2016)
Go 1.5 (August 2015)
Go 1.4 (December 2014)
Go 1.3 (June 2014)
Go 1.2 (December 2013)
Go 1.1 (May 2013)
Go 1 (March 2012)

環境

CentOS release 6.7

epelリポジトリの追加

epelを追加していない場合は追加

$ sudo yum install epel-release

golangのインストール

以下だけ。

$ yum install -y golang

念のため確認

$ go version
go version go1.5.1 linux/amd64

ディレクトリの作成

デフォルトはGOPATHは設定されていないっぽいですが、
GOPATHになり得るディレクトリは/usr/share/gocodeに作成されているので変更する必要がなければ、そのままPATHの設定を行う。
自分は変えたかったので以下を作成

$ mkdir /usr/local/gocode
$ mkdir /usr/local/gocode/{src,bin,pkg}

PATHの設定

yumの場合は/usr/lib/golangにgolangがインストールされるのでGOROOTに指定する。
GOPATHは作成したディレクトリを指定する。

$ echo export GOROOT=/usr/lib/golang >> ~/.bash_profile
$ echo export GOPATH=/usr/local/gocode >> ~/.bash_profile
$ echo export PATH=$PATH:$GOROOT/bin:$GOPATH/bin >> ~/.bash_profile
$ source ~/.bash_profile

以上で完了。

35
31
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
35
31