ftnk.jp -> ~fumi -> ChangeLog -> Go を CentOS にインストールしてみた
Prev / Next / ~fumi/ChangeLog

2009-11-13 / Go を CentOS にインストールしてみた [Linux][Emacs]

Google からプログラミング言語『Go』がリリースされたので,
インストールしてみました.

基本的に,
新プログラミング言語「Go」をCentOSにインストールしてみた « zaru blog
に記載されている通りです.

違いは以下.
- bison のインストール
- Mercurial を rpmforge からインストール
- GOARCH を amd64 に
- go-mode の設定(Emacs)


0. Go の make 時に bison が必要なので,インストール.
$ sudo yum install bison

1. Mercurial をインストール

$ sudo yum --enablerepo=rpmforge install mercurial

rpmforge のリポジトリの追加については[2008-11-30-1]を参照.

2.環境変数の設定

$ export GOROOT=$HOME/go
$ export GOOS=linux
$ export GOARCH=amd64

GOOS と GOARCH の組み合わせは,次の 6 パターン.
linux/amd64, linux/arm, linux/386, darwin/amd64, darwin/386, nacl/386.

~/.zshrc に書いてから

source ~/.zshrc
のほうがいいかも.

どうせ,~/.zshrc にも書くんだし.

3. Go をリポジトリから取得

$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT

4. Go を make & install

$ cd ~/go/src
$ ./all.bash

~/bin に
6a, 6c, 6cov, 6g, 6l, 6nm, 6prof, cgo, ebnflint, godefs, godoc, gofmt
gopack, gotest, goyacc, hgpatch, quietgcc
がインストールされる.

GOARCH=386 の場合は,8a, 8c, 8cov 等.

5. go-mode の設定

~/go/misc/emacs に go-mode.el と go-mode-lode.el があるので設定

~/elisp を load-path に追加してあるので,
~/elisp 以下にリンクをはる.

$ ln -s ~/go/misc/emacs/go-mode* ~/elisp

.emacs.el に以下を追記.

(require 'go-mode-load)
(add-hook 'go-mode-hook
	  '(lambda ()
	     (setq tab-width 4)
	     ))

6.Hello, World!

次の内容で hello.go を作成.

package main
import "fmt"

func main() {
    fmt.Printf("hello, world!\n")
}

$ 6g hello.go
$ 6l hello.6
$ ./6.out
hello, world!

GOARCH=386 の場合は

$ 8g hello.go
$ 8l hello.8
$ ./8.out
hello, world!

関連
- The Go Programming Language
  http://golang.org/
- Installing Go
  http://golang.org/doc/install.html
- 早速 Go 言語を試してみる! - IT戦記
  http://d.hatena.ne.jp/amachang/20091111/1257928890

Blog Widget by LinkWithin
Referrer (Inside):
[2009-11-21-1] go-mode
blog comments powered by Disqus