## 下载 下载地址: https://golang.org/dl ![](https://img.kancloud.cn/e3/cf/e3cfed06c19f95edf5af1933bea4eb78_1450x880.png) 我这里是 windows 64 位,所以选择 go1.15.3.windows-amd64.zip。可以选择下载最新或者其它版本的安装包,只要是 1.11 或以上的版本就行。 ## 安装 解压安装包到安装目录,我这里是 D:\apps\go ![](https://img.kancloud.cn/f5/53/f553eeadebc9f2655dd3b9ef79339aef_932x589.png) ## 配置 环境变量 - GOPATH 这个变量是可选的,如果没有设置默认是 C:\Users\当前登录用户\go,我是 administrator 登录的,所以是 C:\Users\Administrator\go。可以设置这个变量,比如 D:\study\go - GO111MODULE - on - GOPROXY - https://goproxy.cn - PATH - D:\apps\go\bin - %GOPATH%\bin 如果没设置 GOPATH 变量,则是 C:\Users\当前登录用户\go\bin,我是 administrator 登录的,所以是 C:\Users\当前登录用户\go\bin 。如果设置了,比如 D:\study\go,则是 D:\study\go\bin ## 测试 ### 环境变量 ![](https://img.kancloud.cn/37/ef/37ef546260859bfa86bff454d90d4a0d_611x387.png) ## GOPATH\bin ```shell $ echo $GOPATH D:\xxx\study\lang\go $ go get github.com/beego/bee $ which bee /d/xxx/study/lang/go/bin/bee $ bee version 2020/12/11 11:10:34 INFO 鈻?0001 Getting bee latest version... 2020/12/11 11:10:36 WARN 鈻?0002 Update available 1.12.0 ==> 1.12.3 2020/12/11 11:10:36 WARN 鈻?0003 Run `bee update` to update 2020/12/11 11:10:36 INFO 鈻?0004 Your bee are up to date ______ | ___ \ | |_/ / ___ ___ | ___ \ / _ \ / _ \ | |_/ /| __/| __/ \____/ \___| \___| v1.12.0 鈹溾攢鈹€ Beego : Beego is not installed. Please do consider installing it first: https://github.com/astaxie/beego 鈹溾攢鈹€ GoVersion : go1.15.3 鈹溾攢鈹€ GOOS : windows 鈹溾攢鈹€ GOARCH : amd64 鈹溾攢鈹€ NumCPU : 8 鈹溾攢鈹€ GOPATH : D:\xxx\study\lang\go 鈹溾攢鈹€ GOROOT : D:\apps\go 鈹溾攢鈹€ Compiler : gc 鈹斺攢鈹€ Date : Friday, 11 Dec 2020 ``` ## go MODULE ```shell $ mkdir hello $ cd hello/ $ go mod init hello go: creating new go.mod: module hello $ cat main.go package main import "fmt" func main() { fmt.Println("Hello, World") } $ go build hello $ ll -rw-r--r-- 1 Administrator 197121 22 12月 11 11:14 go.mod -rwxr-xr-x 1 Administrator 197121 2141184 12月 11 11:18 hello.exe* -rw-r--r-- 1 Administrator 197121 80 12月 11 11:18 main.go $ ./hello.exe Hello, World ```