五,nexus3搭建golang私服
在之前的文章中提到使用
Athens
搭建golang
私服,但Athens
私服无管理界面,而nexus3
集成了go,maven,docker
等资源的私服功能
搭建nexus3
私服的方法在之前的文章中提过,可参考https://www.jianshu.com/p/62483b0505a5
新建type
为proxy
的go repository
type
为proxy
的go repository
image.png
Remote storage
地址填写镜像站的地址,比较不错的地址有https://mirrors.aliyun.com/goproxy/
、https://goproxy.io
、https://athens.azurefd.net
,proxy
版golang repository
可建立多个。

新建type
为group
的go repository
type
为group
的go repository
image.png

group
版的golang repository
可以从proxy go repository
下载依赖并缓存到本地,将左侧Avaliable
中可用的repository
加入到右侧的Menbers
中,这样就可以从http://192.168.31.230:8081/repository/go-proxy/
中直接下载依赖,nexus
会自动帮我们从proxy go repository
中下载依赖。
设置golang
代理
golang
代理完成上诉步骤之后,还需要设置环境变量启用golang
的代理功能,不同操作系统的设置方式可自行修改,将变量GO111MODULE
设置为on
,GOPROXY
设置为私服的地http://192.168.31.230:8081/repository/go-proxy/
,若是遇到401 Unauthorized
的问题,应该是需要进行nexus3
的用户验证,可以直接在代理地址中加入用户名密码,例如http://username:password@192.168.31.230:8081/repository/go-proxy/
。
若是不想自行搭建私服,也可使用一些现成的镜像站https://goproxy.io
、https://athens.azurefd.net
、或者国内阿里云的https://mirrors.aliyun.com/goproxy/
,只要将环境变量GOPROXY
修改成相应地址即可
作者:褪色的记忆1994
链接:https://www.jianshu.com/p/cdad7d4639e3
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Last updated