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. I suggest using a 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:
12345678910111213 |
/** * my test project:/users/hopkings/www/go/test/ or ~/www/go/test/ * file path:/users/hopkings/www/go/test/ Main.go */ package main import ( "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:
1234567891011121314 |
/**
* 生成编译文件
* @output:
* [ `go build main.go` | done: 1.151276122s ]
*/
go
build main.
go 或
go
build ~/www/Go/Test/main.
go
/**
* 只查看运行结果
* @output:
* hello
*/
go
run main.
go
或
go
run ~/www/Go/Test/main.
go
|
2) terminal operation:
1234567891011121314 |
/**
* 生成编译文件
* @output:
* [ `go build main.go` | done: 1.151276122s ]
*/
go
build ~/www/Go/Test/main.
go
/**
* 只查看运行结果
* @output:
* hello
*/
go
run ~/www/Go/Test/main.
go
|
Here, the development environment for Go has been built. Start coding~
Configuring the Go Development environment under MAC installation