Mac下Golang环境搭建

Mac下Golang环境搭建

Posted by Elton on December 25, 2016

Mac下Golang环境搭建

下载安装Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装Golang

$ brew install go

设置环境变量

$ vim ~/.profile

export GOOROOT=/usr/local/opt/go/libexec/
export GOPATH=~/study/Go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

安装GoCode

为了支持后面Sublime的Go语言自动补全

$ go get github.com/nsf/gocode
$ go install github.com/nsf/gocode

安装Sublime Text3的GoSublime插件

⌘ + ⇧ + P, 调用pakcage control功能, 输入 pci, 然后在输入GoSublime来安装GoSublime插件。

GoSUblime

测试Hello World

package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}

自动补全