Go 编译时使用私有仓库
Go 编译时使用私有仓库
建议点击 查看原文 查看最新内容。
原文链接: https://typonotes.com/posts/2025/03/27/go-build-with-private-bitbucket/
使用私有仓库, 无论如何都需要配置 GOPRIVATE 变量
|
|
1. 本地开发
在本地开发的时候, 通常使用 ssh 协议进行权限验证。
例如 clone 时地址如下格式如下
|
|
则执行如下命令替换验证方式
$ git config --global url.ssh://[email protected]/.insteadOf https://git.example.com/scm/
2. 容器中个编译
在容器中, 通常可以使用 HTTPS Token
$ git config --global url.https://${GIT_CI_SECRET}@git.example.com/scm/.insteadOf https://git.example.com/
注意 如果 username, password 中有特殊符号, 例如 @
或者 /
等, 需要进行 URL 编码
@ -> %40
/ -> %2F
: -> %3A
Dockerfile
|
|
在 docker build
执行编译的景象打包的时候, 使用 --build-arg
传入即可。
|
|
- 原文链接:https://typonotes.com/posts/2025/03/27/go-build-with-private-bitbucket/
- 本文为原创文章,转载注明出处。
- 欢迎 扫码关注公众号
Go与云原生
或 订阅网站 https://typonotes.com/ 。 - 第一时间看后续精彩文章。觉得好的话,请猛击文章右下角「在看」,感谢支持。
