UbuntuにgoogleのGo言語インストール&hello, world

Installing Goを見ながらインストール&「hello, world」

$ cd ~
$ mkdir bin
export GOROOT=$HOME/go
export GOOS=linux
export GOARCH=386
export GOBIN=$HOME/bin
export PATH=$GOBIN:$PATH
$ apt-get install mercurial
$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT
$ ls ~/go/
AUTHORS  CONTRIBUTORS  LICENSE  README  doc  favicon.ico  include  lib  misc  pkg  src  test
  • ビルド
$ cd $GOROOT/src
$ ./all.bash
  :
0 known bugs; 0 unexpected bugs
$vi hello.go
package main

import "fmt"

func main(){
     fmt.Printf("hello, world!!\n")
}
$ 8g hello.go
$ ls hello*
hello.8  hello.go
  • リンク
$ 8l -o hello hello.8
$ ls hello*
hello  hello.8  hello.go
  • 実行
$ ./hello
hello, world!!

デキターーー!
次はDBと接続してみよう!!

  • 参考URL

http://portablecode.info/install_go_lang_on_ubuntu