OS X 10.11 builds the Go language 1.5.1 development environment

Source: Internet
Author: User
Tags sublime text

1. Install Golang SDK
http://golang.org, download the latest installation package, and then double-click Install. Some of the students could not open the domestic ... I just want to say, learn Google things, think of a better way to do it ... You know

After the installation is complete, open the terminal, enter go, or go version (view the installation version) the following information appears to indicate that the installation was successful:

$ go Versiongo version go1.5.1 darwin/amd64

2. Configure Environment variables
After installing the SDK, the next step is to configure the environment variables, open the terminal input CD ~ Enter the user home directory, and then enter the Ls-all command to see if there are any. bash_profile

file that exists both using VIM. Bash_profile to open and edit the file. According to their actual situation, the contents are as follows:

Export Gopath=/users/lvtao/documents/golangexport gobin= $GOPATH/binexport path= $PATH: $GOBIN

Gopath: The root directory for daily development. GOBIN: Is the bin directory under Gopath.

and requires the Gobin directory to be added to the path path, the resulting executable can be run directly.

Exit vim, use source ~/.bash_profile to complete the configuration of the Golang environment variable, you can enter the effect of Go Env view configuration in the terminal:

$ go envgoarch= "AMD64" gobin= "/users/lvtao/documents/golang/bin" goexe= "gohostarch=" AMD64 "gohostos=" Darwin "GOOS=" Darwin "Gopath="/users/lvtao/documents/golang "gorace=" "goroot="/usr/local/go "gotooldir="/usr/local/go/pkg/tool/ Darwin_amd64 "go15vendorexperiment=" "cc=" clang "gogccflags="-fpic-m64-pthread-fno-caret-diagnostics- Qunused-arguments-fmessage-length=0-fno-common "cxx=" clang++ "cgo_enabled=" 1 "

3. Development tool Configuration (sublime text)

Here I choose is sublime text installation Gosublime plug-in development (Golang syntax highlighting hints), the installation method here is not much mention.

After you have configured your development environment, simply do the go language development. Under the SRC directory under your gopath, create a new folder (named after the project name), and then open the folder in Sublime, and the new Main.go file can be encoded.

Package Mainimport ("FMT") func main () {FMT. Println ("Hello");}

After the code is written, use Command+b to open the sublime text terminal, compile it with Go build xx (project name), and compile the resulting information as follows:

[' Go build Main.go ' | done:320.650295ms]

After compiling successfully, execute the shell command and execute the file just after compiling./hellogo to see the results of the operation:

['./main ' | done:12.281054ms] Hello

If you simply want to see the results of the run without producing an executable file (like the file name and project name), you can use go run xxx.go directly in the sublime text terminal:

[' Go run Main.go ' | done:222.787159ms] Hello

So far, we have installed the basic environment for developing GOLANG programs!


OS X 10.11 builds the Go language 1.5.1 development environment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.