How to use Go dep with GitLab subgroups
背景:要拆分项目公共组件,导致go mod 不可避免使用私有仓库的subgroup下面的三方库
现象:每个引用都得用replace
初始怀疑是gitlab版本低的问题
在本地docker启动gitlab-ce 13.8.1 ,无效
使用官方gitlab.com-cc 13.10.0 无效
解决方案
- go env -w GOPRIVATE=gitlabxa.uniontech.com
- go clean -modcache 清除缓存
- 获取一个gitlab Personal Access Tokens (权限是api或者全选)
- 创建 ~/.netrc
machine gitlabxa.uniontech.com
login <your gitlab username>
password <the token created in step 3>
- chmod 600 ~/.netrc
- go mod tidy
参考: