This is a creation in Article, where the information may have evolved or changed.
1, the official website download installs the package (need FQ)
Https://storage.googleapis.com/golang/go1.7.darwin-amd64.pkg
2. Configure GO Environment variables Gopath and Gobin
(1) Open terminal, CD ~
(2) To see if there is a. bash_profile file:
Ls-all
(3) If you skip this step, there is no:
1) Create: Touch. Bash_profile
2) Editor: Open-e. Bash_profile
3) Customize Gopath and Gobin locations:
Export gopath=/users/hopkings/www/goexport GOBIN= $GOPATH/binexport PATH= $PATH: $GOBIN
(4) Compile: source. bash_profile
* View GO Environment variables: Go env
3, install sublime text of Go grammar plugin gosublime;
* Must first configure the GO environment variables Gopath and Gobin, and then install this plug-in, or plug-in will be prompted to find Gopath and gobin;
* I like to use sublime text as a development tool, so this development tool installs the go plugin. You can configure the development environment according to your development tools. The author recommends using the flexible and lightweight sublime Text.
4. Edit Test Demo:
(1) Create a new project (folder) under Gopath, and then create a new test file and save the test content:
/** * My test project:/users/hopkings/www/go/test/ or ~/www/go/test/* file path:/users/hopkings/www/go/test/main.go */package Mainimport ( "FMT") func main () { fmt. Println ("Hello");}
(2) Run the test
You can run the GO command at the terminal, or you can run the Go command in sublime with Cmd+b.
1) Sublime Operation:
/** * Generate compiled Files * @output: * [' Go Build Main.go ' | done:1.151276122s] */go build main.go or go buil D ~/www/go/test/main.go /** * Only view running results * @output: * Hello */go run main.go or Go run ~/ Www/go/test/main.go
2) terminal operation:
/** * Generate compiled Files * @output: * [' Go Build Main.go ' | done:1.151276122s] */GO build ~/www/go/test/m Ain.go /** * View Run results only * @output: * Hello */go run ~/www/go/test/main.go
Here, the development environment for Go has been built. Start coding~