`
stephen830
  • 浏览: 2964661 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics