1. 创建GO语言的源码目录和执行程序的目标目录
mkdir ~/go
mkdir ~/gobin
2. 添加GO语言所需的环境变量
export GOROOT=$HOME/go
export GOARCH=386
export GOOS=linux
export GOBIN=$HOME/gobin
export PATH=$PATH:$GOBIN
退出shell,重新登录,以便重新导入环境变量
3. 安装编译所需的工具包
apt-get install python-setuptools python-dev
sudo apt-get install mercurial
sudo apt-get install bison gcc libc6-dev ed
4. 获取GO语言的源码包
hg clone –r release https://go.googlecode.com/hg/ $GOROOT
5. 编译GO语言包
cd $GOROOT/src
./all.bash
6. helloworld
// filename: HelloWorld.go
package main
import "fmt"
func main() {
fmt.Printf("hello, GO language.../n")
}
6.1 编译: 8g HelloWorld.go
6.2 链接:8l HelloWorld.8
6.3 执行:./8.out
OK
有疑问加站长微信联系(非本文作者)