安装gin

我在安装时出现的主要错误是,个别包get失败,以下是报错(也不算是报错)

github.com/gin-gonic/gin (download)
github.com/gin-contrib/sse (download)
github.com/go-playground/validator (download)
github.com/go-playground/universal-translator (download)
github.com/go-playground/locales (download)
github.com/leodido/go-urn (download)
github.com/golang/protobuf (download)
github.com/ugorji/go (download)
get "gopkg.in/yaml.v2": found meta tag get.metaImport{Prefix:"gopkg.in/yaml.v2", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v2"} at //gopkg.in/yaml.v2?go-get=1
gopkg.in/yaml.v2 (download)
github.com/mattn/go-isatty (download)
unrecognized import path "golang.org/x/sys/unix": https fetch: Get "https://golang.org/x/sys/unix?go-get=1": dial tcp 216.239.37.1:443: i/o timeout

带着上面的错误进行代码的build会报找不到某些东西的错误(这是真的报错)

unrecognized import path "golang.org/x/sys/unix"

可以这样解决

golang.org/x/sys/unix

以下是我中端的代码

~/goproject/src$ mkdir -p golang.org/x
~/goproject/src$ cd golang.org/x
~/goproject/src/golang.org/x$ git clone https://github.com/golang/sys.git
正克隆到 \'sys\'...
remote: Enumerating objects: 213, done.
remote: Counting objects: 100% (213/213), done.
remote: Compressing objects: 100% (122/122), done.
remote: Total 9360 (delta 161), reused 129 (delta 91), pack-reused 9147
接收对象中: 100% (9360/9360), 7.94 MiB | 797.00 KiB/s, 完成.
处理 delta 中: 100% (8046/8046), 完成.

其实关键步骤就是

$ mkdir -p golang.org/x
$ cd golang.org/x
$ git clone https://github.com/golang/sys.git

注意此时所在的目录

然后在build代码就可以成功了

然后gin就完成安装了

设置代理

unset GOPROXY
warning: go env -w GOPROXY=... does not override conflicting OS environment variable
https://goproxy.cn
go env -w GOPROXY=https://goproxy.cn,direct

还有一个地址是https://goproxy.io,我设置的是前者,后者的官网