[tech] Google Goをインストールする(CentOS)
Golangってキーワードがいいのかなあ。。。
http://golang.org/
まずは
$GOROOT、$GOOS 、$GOARCHを設定せいということで、設定。
export GOROOT=$HOME/go export GOOS=linux export GOARCH=386
Mercurialのインストール。で、これはPython-develが入っていないとダメ。
$ sudo easy_install mercurial
はい死亡。
mercurial/base85.c:12:20: error: Python.h: No such file or directory mercurial/base85.c: In function ‘b85prep’: mercurial/base85.c:23: warning: implicit declaration of function ‘memset’ mercurial/base85.c:23: warning: incompatible implicit declaration of built-in function ‘memset’ mercurial/base85.c: At top level: mercurial/base85.c:28: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token mercurial/base85.c:76: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token mercurial/base85.c:141: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘methods’ mercurial/base85.c:150: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘initbase85’ error: command 'gcc' failed with exit status 1
てことで、
$ sudo yum -y install python-devel
まあMercurialはどうでもいい。そんなところでコケてる場合じゃない。
$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT
おいおい
$ sudo apt-get install bison gcc libc6-dev ed
とか書いてあるよ。もっと早く言えよ。
てなわけで
$ yum -y install bison gcc libc6-dev ed
そのまま
$ cd $GOROOT/src $ ./all.bash
$GOBIN is not a directory or does not exist create it or set $GOBIN differently
To build the Go distribution, make sure $GOBIN (or $HOME/bin if $GOBIN is not set) is in your $PATH and then run
あーあーPATH通すのね早く言ってよ
export GOROOT=$HOME/go export GOOS=linux export GOARCH=386 export GOBIN=$HOME/go/bin PATH=$PATH:$GOBIN
ディレクトリもないといけないらしい。
$ . ~/.bashrc $ mkdir $GOBIN $ ./all.bash --- FAIL: os_test.TestRemoveAll RemoveAll "_obj/_TestRemoveAll_" succeeded with chmod 0 subdirectory?(extra *os.PathError=lstat _obj/_TestRemoveAll_: no such file or directory) FAIL make[1]: *** [test] Error 1 make[1]: Leaving directory `/root/go/src/pkg/os' make: *** [os.test] Error 2
がびーん。なう。
そして同じメッセージでぐぐってこんなん見つけた。
http://code.google.com/p/go/issues/detail?id=22
さらにがびーん。
というわけで一般ユーザを作る。
# useradd ito # su - ito
もっかい.bashrcを設定して。。。
$ ./all.bash (略) --- cd ../test 0 known bugs; 0 unexpected bugs
キタコレ!
プログラムを書く
$ cat >hiromi.go <<EOF > package main > import "fmt" > > func main() { > fmt.Printf("Hello, Japan\n") > } > EOF
コンパイルして実行!
$ 8g hiromi.go $ 8l hiromi.8 $ ./8.out Hello, Japan
ジャパーーン!
gccみたいな出力ファイルの指定の場合。
$ 8l -o japan hiromi.8 $ ./japan Hello, Japan