Go是一个由Google团队和开源社区的许多贡献者开发的开源项目. 本文详细记录了Go开发环境搭建过程,包括Go安装,IDE配置等。
系统环境配置
MacOS High Sierra
版本10.13.5
MacBook Pro (Retina, 15-inch, Mid 2015)
处理器 2.2 GHz Intel Core i7
内存 16 GB 1600 MHz DDR3
图形卡 Intel Iris Pro 1536 MB
一、GO 安装
Go官网提供了可用的Go列表,可以直接下载安装。本文主要采用了homebrew工具进行安装,其优点是简单同时也能够在需要的时候利用homebrew进行升级。(HomeBrew安装教程参见 https://brew.sh/)
zhongxiao.yzx@MacBook-Pro:~/Workspace/ $brew info go
go: stable 1.10.3 (bottled), HEAD
Open source programming language to build simple/reliable/efficient software
https://golang.org
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/go.rb
==> Requirements
Required: macOS >= 10.8 ✔
==> Options
--without-cgo
Build without cgo (also disables race detector)
--without-race
Build without race detector
--HEAD
Install HEAD version
==> Caveats
A valid GOPATH is required to use the `go get` command.
If $GOPATH is not specified, $HOME/go will be used by default:
https://golang.org/doc/code.html#GOPATH
You may wish to add the GOROOT-based install location to your PATH:
export PATH=$PATH:/usr/local/opt/go/libexec/bin
zhongxiao.yzx@MacBook-Pro:~/Workspace $brew install go
Updating Homebrew...
warning: unable to access '/Users/zhongxiao.yzx/.config/git/ignore': Permission denied
warning: unable to access '/Users/zhongxiao.yzx/.config/git/attributes': Permission denied
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Renamed Formulae
cdiff -> ydiff
==> Downloading https://homebrew.bintray.com/bottles/go-1.10.3.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring go-1.10.3.high_sierra.bottle.tar.gz
==> Caveats
A valid GOPATH is required to use the `go get` command.
If $GOPATH is not specified, $HOME/go will be used by default:
https://golang.org/doc/code.html#GOPATH
You may wish to add the GOROOT-based install location to your PATH:
export PATH=$PA