Go Google's own language is a compiled language designed without loss of performance under the premise of reducing code complexity rates. Its advantage is the software to give full play to multi-core processors synchronous multiplex advantage, and solve problems of object-oriented programming.
First, install the SDK Golang
The official website http://golang.org/ directly download the installation package can be installed. Download the latest installation package pkg format, double click to run all the way to follow the prompts to complete the installation.
After installation is complete, open a terminal, enter go, detection Golang SDK is installed successfully, as shown below, the installation was successful
You can also enter go version check the version you have installed Golang
Second, the environment variable configuration (GOPATH)
GOPATH command is used to tell Golang and other related tools, where to find Go package directory on your system.
GOPATH is a list of paths similar to PATH settings:
GOPATH = / home / USER / go: / home / USER / workspace_go: ***
Path each list item are actually a work space, each work area should include the source files (src), the relevant package (pkg), executable files (bin) three directories.
After you have completed the workspace, you can start configuring the GOPATH (configuration file is ~ / .bash_profile).
export GOPATH = / Users / heinoc / go: / Users / heinoc / Documents / workspace / workspace_go
After saving, source ~ / .bash_profile it, completes the GOPATH configuration, you can look at the terminal go env effect after configuration.
(Note: I generally give GOPATH with at least two directories, you need to download the source packet (go get ****), the first open source packages by default will find a directory, will be unified under the first directory pkg folder, I local development projects are all stored in the back of GOPATH directory is to facilitate management pack, how to configure, see your personal preference)
Third, the development tool configuration (Sublime Text 2)
Sublime Text 2 Download: http: //www.sublimetext.com/2
Once downloaded can be installed directly.
Sublime Text 2 is free to use, but after a certain number of times to save will be prompted whether to buy, click Cancel to continue to use, and officially registered version does not make any difference.
1. Install Package Control
Ctrl + `to open the command line, use the following code:
import urllib2, os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path (); os.makedirs (ipp) if not os.path.exists (ipp) else None; urllib2.install_opener (urllib2.build_opener (urllib2.ProxyHandler ())); open (os.path.join (ipp, pf), 'wb') .write (urllib2.urlopen ( 'http://sublime.wbond.net/'+pf.replace ( '', '% 20')) read ());. print 'Please restart Sublime Text to finish installation'
After the restart Sublime Text 2
This indicates that the installation was successful Package Control.
2. Install GoSublime plugin:
Command + Shift + P to open the Package Control, and then enter pcip (Package Control: Install Package Abbreviation)
Enter GoSublime in subsequent interface, carriage return, you can install the GoSbulime.
After installation is complete, you can see in the menu
Here, Sublime Text Golang development environment to build 2 complete.
Fourth, start Golang
GOPATH in your work space, create a folder under the src directory, named after the project, and then drag the folder Sublime Text 2, you can open the project in Sublime Text 2, and then create a new file in there save as "***. go" can, then you can start coding
For the preparation of good document, use the keyboard shortcut Command + B terminal open Sublime Text 2, enter go build (name) to be compiled
Tip compilation is successful, then execute shell commands, execute files just compiled ./gotest you can see the results of the program.