安装 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:""} at //gopkg.in/yaml.v2?go-get=1gopkg.in/yaml.v2 (download)github.com/mattn/go-isatty (download)unrecognized import path "golang.org/x/sys/unix": https fetch: Get "?go-get=1": dial tcp 216.239.37.1:443: i/o timeout带着上面的错误进行代码的 build 会报找不到某些东西的错误(这是真的报错)根据 unrecognized import path "golang.org/x/sys/unix",可知是缺少了某些东西。怎样解决照着命令行报的错误,进行解决,在 src 下面构造 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 注意:此时所在的目录然后在 build 代码就可以成功了,gin 就完成安装了。设置代理
unset GOPROXY 可以解决设置代理报错的问题,这是在安装 gin 过程中学到的
报的错为:warning: go env -w GOPROXY=... does not override conflicting OS environment variable
笔者这里设置的代理为 命令为 go env -w GOPROXY=,direct还有一个地址是 ,笔者设置的是前者,后者的官网
扫描二维码
咨询详情 >
51Reboot