登录
首页 >  Golang >  Go问答

使用HTTP代理下载Go软件包

来源:stackoverflow

时间:2024-03-04 09:18:25 190浏览 收藏

在IT行业这个发展更新速度很快的行业,只有不停止的学习,才不会被行业所淘汰。如果你是Golang学习者,那么本文《使用HTTP代理下载Go软件包》就很适合你!本篇内容主要包括##content_title##,希望对大家的知识积累有所帮助,助力实战开发!

问题内容

我正在尝试通过我的 http_proxy 下载 go 软件包。 现在,我已经编辑了 .gitconfig,它看起来像:

[http]
        proxyauthmethod = basic
        sslverify = false
        proxy = http://mydomain\\username:passwd@myproxy:8080
[credential "http://myproxy:8080"]
        provider = generic
[https]
        proxyauthmethod = basic
        sslverify = false
        proxy = http://mydomain\\username:passwd@myproxy:8080

通过代理进行 git 克隆工作正常(这意味着我的代理工作正常):

$ git clone https://github.com/clickhouse/clickhouse-go.git -v
cloning into 'clickhouse-go'...
warning: ----------------- security warning ----------------
warning: | tls certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: https connections may not be secure. see https://aka.ms/gcm/tlsverify for more information.
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
post git-upload-pack (185 bytes)
post git-upload-pack (gzip 4262 to 2162 bytes)
remote: enumerating objects: 7076, done.
remote: counting objects: 100% (368/368), done.
remote: compressing objects: 100% (116/116), done.
remote: total 7076 (delta 258), reused 359 (delta 251), pack-reused 6708
receiving objects: 100% (7076/7076), 2.52 mib | 5.12 mib/s, done.
resolving deltas: 100% (4915/4915), done.

但是当我尝试使用 go mod tidy 添加 go 模块时,我收到此错误:

PS C:\Users\user\go\src> go mod tidy
go: finding module for package github.com/ClickHouse/clickhouse-go/v2
main imports
        github.com/ClickHouse/clickhouse-go/v2: module github.com/ClickHouse/clickhouse-go/v2: Get "https://proxy.golang.org/github.com/%21click%21house/clickhouse-go/v2/@v/list": proxyconnect tcp: dial tcp: lookup http: no such host

我应该配置什么才能让 go mod tidy 工作?


正确答案


您能否确认您的代理设置符合您的预期?

尝试在控制台中输入 go env 并检查 GOPROXY 的值。

今天关于《使用HTTP代理下载Go软件包》的内容就介绍到这里了,是不是学起来一目了然!想要了解更多关于的内容请关注golang学习网公众号!

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