Go Get下载私有仓库的依赖
source link: https://shingle.me/post/go-get%E4%B8%8B%E8%BD%BD%E7%A7%81%E6%9C%89%E4%BB%93%E5%BA%93%E7%9A%84%E4%BE%9D%E8%B5%96/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Go Get下载私有仓库的依赖
由于 go get 是基于 git 系统去下载仓库的, 所以直接用 git 的思路去解决.
这里以 gitlab 的私有仓库为例
-
登录 gitlab, 点击个人头像下的
setting
, 选择Access Tokens
-
选择给该 token 的权限, 然后创建一个 token
-
执行命令,
${GITLAB_TOKEN}
需要替换成你自己的 token, 这会将git 访问的所有 gitlab.com 替换为带 token 的 gitlab.git config --global url."https://https://oauth2:${GITLAB_TOKEN}@gitlab.com/".insteadOf "https://gitlab.com/"
如果只想局部替换, 可以自己修改 path, 因为某些公共库可能放在
gitlab 上
git config --global url."https://https://oauth2:${GITLAB_TOKEN}@gitlab.com/xxx/".insteadOf "https://gitlab.com/xxx/"
其他私有仓库同理, 只是认证链接不同, 可以自行查看对应的 api 文档.
github 的认证链接貌似是https://${GITHUB_TOKEN}:[email protected]
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK