Installation
Golang official website
Golang Chinese Learning Network
Image
Download the corresponding installation package according to your system
Setting environment variables
# 我是 mac 系统默认是装在/usr/local 下的,也可以自己选择想要安装的路径# windows用户自行百度如何修改环境变量,这里不多做介绍export GOROOT=/usr/local/goexport PATH=$PATH:$GOROOT/binexport GOPATH=/Users/yejunyu/go/goget:/Users/yejunyu/go/gowork
Here Gopath said, each go directory has
srcStore source code (e.g.,. Go. C. h, etc.)
pkgIntermediate files generated at compile time (for example:. a)
binGenerated executables after compilation
gorootWhere Google's official standard library and execution files are stored
gopathis a self-setting place to store the source code
I used two of them gopath , separated by : Windows users ; .
The first to hold a third-party library (go get the Library), the second can put your own writing source
Verify
go version
Image
The description is ready to use
package mainfunc main(){ println("hello world")}
International practice, output ahello world
The next section formally begins the journey of Golang, Lang rise ~