登录
首页 >  Golang >  Go问答

使用代理克隆 go-git 仓库

来源:stackoverflow

时间:2024-02-22 20:27:19 161浏览 收藏

珍惜时间,勤奋学习!今天给大家带来《使用代理克隆 go-git 仓库》,正文内容主要涉及到等等,如果你正在学习Golang,或者是对Golang有疑问,欢迎大家关注我!后面我会持续更新相关内容的,希望都能帮到正在学习的大家!

问题内容

我在 golang 上编写了一个小应用程序,并使用 go-git 克隆 git 存储库,但是当我通过代理运行它时,它无法连接到互联网。 下面一段代码:

url := os.Getenv("APP_DOWNLOAD_LOCATION")
username := "username"
password := "password"
if len(username) > 0 && len(password) > 0 {
    cloneOptions.Auth = &http2.BasicAuth{
        Username: username,
        Password: password,
    }
    cloneOptions.
}
r, err := git.Clone(storer, fs, cloneOptions)

我搜索过,但没有任何配置 go-git 通过代理克隆的指南。 有人遇到过这种情况吗? 非常感谢。


解决方案


auth/basic/username_password/main.go 似乎不适用于代理身份验证。

对于代理,您需要设置一个自定义客户端(如 _examples/custom_http/main.go 中的 http.Transport set with your credentials

本篇关于《使用代理克隆 go-git 仓库》的介绍就到此结束啦,但是学无止境,想要了解学习更多关于Golang的相关知识,请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>