MAC下安装 golang
Unix下安装Go语言 超级方便,不多说了 直接上代码
mac下需要安装xcode才可以编译
另外安装brew 这个mac下的包管理软件也很方便
先安装Mercurial 包
<pre>sudo easy_install mercurial #安装hg 是 类似git的另一中版本管理软件 brew search go brew install go /usr/local/bin/hg==> Cloning http://go.googlecode.com/hg/ Updating /Users/darkhucx/Library/Caches/Homebrew/go--hg pulling from http://go.googlecode.com/hg/ searching for changes adding changesets adding manifestsadding file changesadded 11 changesets with 56 changes to 44 files (run 'hg update' to get a working copy)44 files updated, 0 files merged, 0 files removed, 0 files unresolved ==> Checking out revision release ==> ./all.bash/usr/local/Cellar/go/HEAD: 1797 files, 104M, built in 5.0 minutes </pre>
编译完成,将go的路径加入 profile文件中去
mate ~/.profile #go lang path export PATH=/usr/local/Cellar/go/HEAD/bin:$PATH source ~/.profile
完成go的安装,写段代码测试
package main
import "fmt"
func main(){
fmt.Printf("hello world,你好 世界\n")
}
6g hello.go #编译
6l hello.6
./6.out #完成