英文:
go get PRIVATE repo with proxy
问题
我的公司提供了一个VPN,但只提供了全局代理,所以我在Docker中启动了一个VPN,并向外部提供了socks5代理,我希望能够使用我本地启动的socks5代理来执行go get ≈ <private_repo_path>
。
我的配置文件
- Go环境
GOPRIVATE="<company_gitlab_url>"
GOPROXY="http://goproxy.cn,direct"(我在中国,这是中国的Golang代理)
- Git
[http "https://<company_gitlab_url>"]
proxy = socks5://127.0.0.1:1080
insteadOf = http://<company_gitlab_url>/
insteadOf = http://<company_gitlab_url>/
- netrc
machine <company_gitlab_url>
login username
password accessToken
我期望git clone <company_gitlab>/<repo_name>
命令使用socks5代理,所以我为git配置了http代理,它可以正常工作。
[http "https://<company_gitlab_url>"]
proxy = socks5://127.0.0.1:1080
但是go get <company_gitlab>/<repo_name>
不起作用(没有使用socks5代理)。
我知道go get
本质上是git clone
,而且我已经设置了ssh insteadOf http
,所以我认为我应该配置一个SSH代理:
所以我在.ssh/config中添加了以下配置:
Host <company_gitlab_url>
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
但是它不起作用。
go get <company_gitlab_url>/<repo_name>
显示:
>go get: 无法识别的导入路径"<company_gitlab_url>/golang/base":https获取:获取"https://<company_gitlab_url>/golang/base?go-get=1"时出错:拨号tcp 10.130.xxx.xxx:443:i/o超时
我认为10.130.xxx.xxx是我公司Gitlab.net的内部IP,我该怎么办?
英文:
My company provides a VPN, but only a global proxy, so I started a vpn in docker and provided the sock5 proxy to the outside, and I wanted go get ≈ <private_repo_path>
use my locally started sock5 proxy.
my configuration file
- Go env
```
GOPRIVATE="<company_gitlab_url>"
GOPROXY="http://goproxy.cn,direct" (I'm in China. This is CN Golang Proxy)
```
- Git
```
[http "https://<company_gitlab_url>"]
proxy = socks5://127.0.0.1:1080
insteadOf = http://<company_gitlab_url>/
insteadOf = http://<company_gitlab_url>/
```
- netrc
```
machine <company_gitlab_url>
login username
password accessToken
```
I'm expecting the git clone <company_gitlab>/<repo_name>
command use the sock5 proxy,so I've configured the http proxy for git, it works
[http "https://<company_gitlab_url>"]
proxy = socks5://127.0.0.1:1080
But go get <company_gitlab>/<repo_name>
not work (not use the sock5 proxy)
Knowing that go get
is essentially git clone
and that I have ssh insteadOf http
set up, I thought I should configure an SSH proxy:
So I added the following configuration to .ssh/config
Host <company_gitlab_url>
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
But it doesn't work
go get <company_gitlab_url>/<repo_name>
shows
>go get: unrecognized import path "<company_gitlab_url>/golang/base": https fetch: Get "https://<company_gitlab_url>/golang/base?go-get=1": dial tcp 10.130.xxx .xxx:443: i/o timeout
I think 10.130.xxx.xxx is the internal IP of my company Gitlab.net, what should I do?
答案1
得分: 3
我修复了,go get xx
不仅使用 SSH,还有一次 HTTP 获取。
所以使用 https_proxy(http_proxy)=sock5://xxx go get xxx
命令。
英文:
I fix it,go get xx
not only use ssh,and has once http fetch。
so use https_proxy(http_proxy)=sock5://xxx go get xxx
command
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论