googleのGoをインストール
今年のGoogle Developer Day 2011のdevquizでgoogleが開発した
プログラミング言語Goの問題があったので、ついカッとなってインストールしてみた。
Mercurialが必要とのことなのでpythonを入れてみる。
バージョン管理システムはsubversionとgitしか使ったことがない。
Mercurialもいい機会なので使ってみようと思う。
なんかpythonは普通に入ってたのでpython-setuptoolsを入れる。
yum install python-setuptools
Mercurialのインストール
easy_install mercurial ... error: Setup script exited with Python headers are required to build Mercurial
なんか怒られた。。。
python-develも入れなきゃダメだった。
yum install python-devel
これでMercurialが入った。
hg version Mercurial Distributed SCM (version 1.9.1) (see http://mercurial.selenic.com for more information) Copyright (C) 2005-2011 Matt Mackall and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ここからはGoの設定
32bit か 64bitか確認
getconf LONG_BIT
32
環境変数を設定する。.bashrcに下記を追加
export GOROOT=$HOME/htdocs/go export GOOS=linux export GOARCH=386 export GOBIN=$HOME/bin export PATH=$PATH:$GOBIN
確認
source .bashrc env | grep '^GO'
binディレクトリ作成
cd; mkdir bin
Goをリポジトリから入手
hg clone -r release https://go.googlecode.com/hg/ $GOROOT
いよいよGoのインストール!
cd htdocs/go/src
./all.bash
ちょっと時間かかって....
N known bugs; 0 unexpected bugs
インストール完了っ!
mkdirしたbinの中にバイナリファイルができてる。
ls
6cov 6prof 8c 8l ebnflint godoc gofmt gomake gopprof gotry govet hgpatch
6nm 8a 8g cgo godefs gofix goinstall gopack gotest gotype goyacc quietgcc
サンプルスクリプトを動かしてみる。
hello.go
package main import fmt "fmt" // 入出力フォーマットを実装したパッケージ func main() { fmt.Printf("Hello, world\n") }
32bitなので8g 8lを使用する。
8g hello.go ls hello.8 hello.go 8l hello.8 ls 8.out hello.8 hello.go
できたー。あとは実行!
./8.out Hello, world
動いたー!
ちょっとこれで色々やってみようと思う。