mac os 搭建golang
1.下载:golang安装包:http://code.google.com/p/go/downloads/list
2.安装go1.xx.darwin-amd64.pkg ,安装完成后会在mac os 自动创建目录:/usr/local/go/
3.打开终端修改环境配置:
$ sudo vim ~/.bash_profile
在bash_profile文件里添加
export GOROOT=/usr/local/go
export GOARCH=amd64
export GOOS=darwin
export PATH=$PATH:$GOROOT/bin
然后$qw保存退出
激活配置:
$ source ~/.bash_profile
这样就可以在终端里输入命令:go version
go version go1.3 darwin/amd64
配置成功!
新建一个hello.go的文件:
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
运行: go run hello
页:
[1]