对于公司的私有Gitlab仓库,没有对https支持,在使用最新版本的go get命令时,需要使用-insecure参数来支持http,但如果导入的包里边依赖了需要https的仓库,就不好使了
一、为Gitlab添加SSH Keys
二、配置.gitconfig文件
git config –global url.”git@git.mygitlab.com:”.insteadOf “https://git.mygitlab.com”
https://www.cnblogs.com/mm200p/p/6626111.html
https://zhuanlan.zhihu.com/p/89511464
https://blog.csdn.net/Yuhao818/article/details/100557931
docker登录私库时提示 x509: certificate signed by unknown authority
打开daemon.json
sudo vi /etc/docker/daemon.json
加入insecure-registries
{
“insecure-registries”:[“私库地址”]
}
https://blog.csdn.net/liusf1993/article/details/102508663
https://www.cnblogs.com/YYRise/p/11589335.html
https://stackoverflow.com/questions/53211703/x509-certificate-signed-by-unknown-authority-go-pingdom
curl -ikv https:
go get -insecure https://blog.zhaoweiguo.com/2019/09/24/golang-env-private-git/
apk add openssl apk add ca-certificates
error: cannot run ssh: No such file or directory fatal: unable to fork
apk update apk add –no-cache openssh
https://cloud.tencent.com/developer/ask/184607
通过以下配置,可以实现更新支持https协议的私有库依赖。
设置 GOPRIVATE 环境变量 go env -w GOPRIVATE=private.repo.com
修改git的全局配置
git config –global url.”ssh://git@private.repo.com”.insteadOf “https://private.repo.com”
然而如果私有库不支持https协议,会报如下的错误。这是因为Go更新依赖时,会强制校验CA证书来确保依赖库的安全性。
go: private.repo.com/modules/project@v0.0.0-20200320063051-28c4ad7fe2ea: unrecognized import path “private.repo.com/modules/project”: https fetch: Get “https://private.repo.com/modules/project?go-get=1”: dial tcp 123.123.123:443: connect: connection refused
如果要更新不支持https协议的私有库,还需再做如下的配置。
git config –global url.”ssh://git@private.repo.com”.insteadOf “http://private.repo.com”
1) 使用 go get -insecure
这种方式不推荐,原因如下
添加 -insecure 参数即表示更新依赖时可以不去校验CA证书,但是这会带来一个问题:范围无法界定(overkill),所有与要更新依赖相关联的依赖,均不会去做校验,可能会意外更新到不安全的依赖。
-insecure 仅支持 go get 命令,不支持 go mod 命令,因此使用 go mod 命令时是无法更新不支持https协议的私有库的。
2) 添加 GOINSECURE 参数
推荐这种方式
在Go 1.14中增加了新的环境变量,用于指定哪些域名下的仓库不去校验CA证书。
使用方式同 GOPRIVATE 类似 go env -w GOINSECURE=private.repo.com
https://www.cnblogs.com/hiwz/p/12652153.html
https://www.digitalocean.com/community/questions/curl-not-working-ssl
https://www.szyhf.org/2017/07/12/%E5%BD%93go-get%E9%81%87%E4%B8%8Agitlab/
https://cloud.tencent.com/developer/article/1794683
https://blog.zhaoweiguo.com/2019/09/24/golang-env-private-git/
https://stackoverflow.com/questions/128035/how-do-i-pull-from-a-git-repository-through-an-http-proxy
端口号根据自己的代理端口进行修改,一般 ss 是1080,v2ray 是 1081
git config –global http.proxy ‘socks5://127.0.0.1:1080’
git config –global https.proxy ‘socks5://127.0.0.1:1080’
https://segmentfault.com/a/1190000018813121
https://blog.csdn.net/isea533/article/details/84748009
https://www.jianshu.com/p/a9ab88fc342f
https://stackoverflow.com/questions/31588869/git-received-http-code-503-from-proxy-after-connect
https://blog.csdn.net/weixin_41010198/article/details/109327793
https://blog.csdn.net/weixin_42296780/article/details/97809703
配置 git 的 http https 代理
配置 git 的 ssh 代理
https://blog.csdn.net/taotieren/article/details/105646004
https://www.newlearner.site/2018/08/29/surge-for-mac.html
https://github.com/gomods/athens
https://bbs.huaweicloud.com/blogs/detail/151161
https://github.com/Wollender/gitlab-docker-k8s
https://blog.csdn.net/u011142688/article/details/80372573
https://kuboard.cn/learning/k8s-intermediate/private-registry.html#%E5%89%8D%E6%8F%90%E5%81%87%E8%AE%BE
https://github.com/eip-work/kuboard-press
https://www.cloudbees.com/blog/using-docker-behind-a-proxy
https://erwinvaneyk.nl/private-repositories-with-go-mod/
https://stackoverflow.com/questions/19643946/dockerfile-for-cloning-private-git-repo
https://vsupalov.com/build-docker-image-clone-private-repo-ssh-key/
https://medium.com/paperchain/fetching-private-github-repos-from-a-docker-container-273f25ec5a74
https://stackoverflow.com/questions/62960934/building-go-apps-with-private-modules-in-docker
https://stackoverflow.com/questions/52209721/go-mod-private-repo
https://divan.dev/posts/go_get_private/
https://dev.to/gopher/how-to-use-go-modules-with-private-git-repository-53b4
https://www.smartystreets.com/blog/2018/09/private-dependencies-in-docker-and-go/
https://frontdeveloper.pl/2020/01/go-modules-versus-docker/
https://www.gitdig.com/post/go-get-private-github-repo/
https://jfrog.com/blog/why-goproxy-matters-and-which-to-pick/
https://stackoverflow.com/questions/27500861/whats-the-proper-way-to-go-get-a-private-repository
https://tonybai.com/2018/11/26/hello-go-module-proxy/