This is a creation in Article, where the information may have evolved or changed.
Download Golang installation package
Download Address: Http://www.golangtc.com/download
Https://code.google.com/p/go/downloads/list
| Go1.4.darwin-amd64-osx10.8.pkg |
go1.4 Mac OS X (x86 64-bit) PKG Installer |
Setting environment variables
Configure Goroot and Gopath:
To create a directory under the Go folder: mkdir ~/go The following things put to. BASH_RC (or maybe. bash_profile or. zshrc) export Goroot=/usr/local/go export gopath= $HOME/ Goexport path= $PATH: $GOROOT/bin
Download Pkg under Mac Double-click Install, super simple, default installation path:/usr/local/go
SOURCE ~/.bash_profile
Now that the Golang installation is complete, let's experience the following:
Go env go version
Run Result: Liuxinmingdemacbook-pro:gotest liuxinming$ go envgoarch= "amd64" gobin= "" gochar= "6" goexe= "" Gohostarch= "AMD64" Gohostos= "Darwin" goos= "Darwin" Gopath= "/users/liuxinming/go" gorace= "goroot="/usr/local/go "gotooldir="/usr/ Local/go/pkg/tool/darwin_amd64 "cc=" clang "gogccflags="-fpic-m64-pthread-fno-caret-diagnostics-qunused-arguments -fmessage-length=0-fno-common "cxx=" clang++ "cgo_enabled=" 1 "=========== ornate split line =============== Liuxinmingdemacbook-pro:gotest liuxinming$ Go versiongo version go1.4 darwin/amd64liuxinmingdemacbook-pro:gotest liuxinming$
Development tool Configuration (Sublime Text 2)
Sublime Text 2 Download Address: HTTP://WWW.SUBLIMETEXT.COM/2
After downloading, you can install directly.
Sublime Text 2 can be used for free, just after a certain number of save times will be prompted whether to buy, click Cancel can continue to use, and the official registration version no difference.
Start Golang Journey
Command + Shift + P to open the package Control and enter go, return (the code hint will appear)
Create a new Hello.go
Package Mainimport "FMT" Func Main () { fmt. Printf ("Hello, world\n")}
For a well-written file, use the shortcut key command + B to open the terminal of Sublime Text 2, enter the Go Build (name) to compile it: "Note: I test, the direct shortcut is automatically compiled, no input required"
The problem is that the default installed sublime does not have go build, so you need to create one yourself.
Add the Go language build for sublime Text2
Tools-Build system-New build system
Enter the following code:
{ "cmd": ["/usr/local/go/bin/go", "Run", "$file"], "File_regex": "^ (... *):( [0-9]*):? ([0-9]*) ", " Working_dir ": " ${file_path} ", " selector ": " Source.go " }
then select the file for build: Go
then COMMAND + B will have the output.