`

Say "Hello,world!" with google's go language on ubuntu9.10

    博客分类:
  • go
阅读更多
ref: http://golang.org/doc/install.html

Install go and say hello

* step1:add variables to PATH
for example:

export GOROOT=/home/eric/program/go
export GOARCH=386
export GOOS=linux

different os,cpu has different value,refer to:http://golang.org/doc/install.html

make sure user has permission to operate GOROOT folder and create it,if not,install might be fail,

there is another var $GOBIN which is optional,default to $HOME/bin,so you need to create $HOME/bin if not exist,or you can specify it in PATH as above three var(but when I try to specify it,I failed,so I use the default $HOME/bin,of cause I create it first).

* step2: make sure PATH is ok
logout and login so than the PATH change,then use follow commond to test whether PATH is correct:
 $ env | grep '^GO'


* step3:Fetch the repository
install mercurial first with follow commond:
sudo apt-get install mercurial


get repository with follow commond:
$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT


* step4:install some required thing
$ sudo apt-get install bison gcc libc6-dev ed make


* step5:install go
$ cd $GOROOT/src
$ make all


If "make all" goes well, it will finish by printing:

--- cd ../test
N known bugs; 0 unexpected bugs

* step6:
you have finish install go on ubuntu9.10,
you might need relogin,I don't need on standalone linux,but need on vmware,

* step7:say hello
cd ~
gedit hello.go

hello.go:
package main
import "fmt"
func main() {
	fmt.Printf("hello, world\n")
}

compile hello.go,take 386 cpu for example,with other cpu,refer to http://golang.org/doc/install.html
8g hello.go
8l hello.8

run it:
./8.out

"hello,world"    here we go,finish!

*
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics