服务搭建
- 基于nexus3镜像构建服务
- 配置docker-compose.yml
version: "3"
services:
nexus:
image: sonatype/nexus3:3.17.0
ports:
- "80:8081"
volumes:
- "./nexus-data:/nexus-data"
athens:
image: gomods/athens:latest
ports:
- "3001:3001"
代理设置
- 设置代理源
- 项目设置代理:
export GOPROXY=http://101.43.58.68/repository/go2/ - go mod tidy获取包,同时会在nexus远程仓库下载对应的包以及依赖
注意事项
Get"https://sum.golang.org/lookup/github.com/tidwall/sjson@v1.2.5": dial tcp 172.217.163.49:443: i/o timeout情况,因为官方引入了sumdb的校验,这个校验的概念是所有公共的包都会在官方的sumdb中存有一份校验值,以防止一些恶意劫持篡改的情况发生。官方的sumdb地址为:sum.golang.org (opens new window),当我们构建的时候,连到这个地址去校验包,往往都是超时的。
推荐设置:
export GOPROXY="http://nexus.eryajf.net/repository/go-group/"
export GONOSUMDB="gitlab.eryajf.net",
export GOSUMDB="sum.golang.google.cn"