CentOS下go 安装
go 语言源码安装依赖 ,gcc ,make glibc库,等,上述工具安装省略,另外,其源代码更新采用的是mercurial 工具,安装前先安装mercureal :
1.mercurial安装使用
yum install mercurial
2.设置环境变量在.bash_profile中
#go set
export GOROOT=/usr/local/go
export GOOS=linux
export GOARCH=386
export GOBIN=$GOROOT/bin
PATH=$PATH:$GOBIN
export PATH
alias cdg="cd /project/go"
2.下载go安装包:
hg clone -r release https://go.googlecode.com/hg/ $GOROOT
cd $GOROOT/src && ./all.bash
3.运行go 看是否能找到命令
4.编写demo程序验证下:1.编写demo程序:
1>编译运行:
go run demo.go
2>单步编译,单步连接
[root@andes.com /project/go]#ls
demo.go
[root@andes.com /project/go]#go tool 8g demo.go
[root@andes.com /project/go]#ls
demo.8 demo.go
[root@andes.com /project/go]#go tool 8l demo.8
[root@andes.com /project/go]#ls
8.out demo.8 demo.go
[root@andes.com /project/go]#8.out
Let's go
5.添加vim 对go支持
将/go/misc/vim 下相关文件拷贝到$HOME/.vimrc
2.设置环境变量在.bash_profile中
#go set
export GOROOT=/usr/local/go
export GOOS=linux
export GOARCH=386
export GOBIN=$GOROOT/bin
PATH=$PATH:$GOBIN
export PATH
alias cdg="cd /project/go"
2.下载go安装包:
hg clone -r release https://go.googlecode.com/hg/ $GOROOT
cd $GOROOT/src && ./all.bash
3.运行go 看是否能找到命令
4.编写demo程序验证下:1.编写demo程序:
demo.go package main import "fmt" func main() { fmt.Printf("Let's go\n") }
1>编译运行:
go run demo.go
2>单步编译,单步连接
[root@andes.com /project/go]#ls
demo.go
[root@andes.com /project/go]#go tool 8g demo.go
[root@andes.com /project/go]#ls
demo.8 demo.go
[root@andes.com /project/go]#go tool 8l demo.8
[root@andes.com /project/go]#ls
8.out demo.8 demo.go
[root@andes.com /project/go]#8.out
Let's go
5.添加vim 对go支持
将/go/misc/vim 下相关文件拷贝到$HOME/.vimrc