5

Go Get下载私有仓库的依赖

 2 years ago
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.
neoserver,ios ssh client

Go Get下载私有仓库的依赖

2019-03-12 19:43:22 约 263 字 预计阅读 1 分钟 297 次阅读

由于 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]

文章作者 shingle (如需转载请注明本文链接,违者必究)

上次更新 2019-03-12 19:43:22

许可协议 CC BY-NC-ND 4.0

赞赏支持 赞赏列表

Protoc使用不同的代码生成插件protoc-gen-go Vscode配置proto插件


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK