英文:
Why doesn't "go get gopkg.in/..." work while "go get github.com/..." OK?
问题
我尝试使用go get gopkg.in/fatih/pool.v2
根据Readme.md
安装pool,但无法成功:
C:\Users\xiaona\Documents\GitHub> go get -v gopkg.in/fatih/pool.v2
Fetching https://gopkg.in/fatih/pool.v2?go-get=1
https fetch failed.
Fetching http://gopkg.in/fatih/pool.v2?go-get=1
import "gopkg.in/fatih/pool.v2": http/https fetch: Get http://gopkg.in/fatih/poo
l.v2?go-get=1: dial tcp 107.178.216.236:80: ConnectEx tcp: A connection attempt
failed because the connected party did not properly respond after a period of ti
me, or established connection failed because connected host has failed to respon
d.
package gopkg.in/fatih/pool.v2: unrecognized import path "gopkg.in/fatih/pool.v2
"
在Web浏览器中访问`107.178.216.236:80`是可以的。
我尝试使用`go get github.com/fatih/pool`,它也可以正常工作。
有人能给出一些关于这个问题的线索吗?
顺便说一下:我使用的是`Windows PowerShell`,`git`版本是`1.9.5`。
<details>
<summary>英文:</summary>
I try to use `go get gopkg.in/fatih/pool.v2` to install [pool](https://github.com/fatih/pool) according to `Readme.md`, but can't success:
C:\Users\xiaona\Documents\GitHub> go get -v gopkg.in/fatih/pool.v2
Fetching https://gopkg.in/fatih/pool.v2?go-get=1
https fetch failed.
Fetching http://gopkg.in/fatih/pool.v2?go-get=1
import "gopkg.in/fatih/pool.v2": http/https fetch: Get http://gopkg.in/fatih/poo
l.v2?go-get=1: dial tcp 107.178.216.236:80: ConnectEx tcp: A connection attempt
failed because the connected party did not properly respond after a period of ti
me, or established connection failed because connected host has failed to respon
d.
package gopkg.in/fatih/pool.v2: unrecognized import path "gopkg.in/fatih/pool.v2
"
While access `107.178.216.236:80` is OK in web browser.
I try to use `go get github.com/fatih/pool`, and it also works OK.
Could anyone give some clues on this issue?
BTW: I use `windows powershell` and `git` version is `1.9.5`.
</details>
# 答案1
**得分**: 0
已找到根本原因:因为我的计算机使用了网络代理,所以我需要在环境变量中设置代理:
C:\Users\xiaona>set https_proxy=https://web-proxy.corp.hp.com:8080/
C:\Users\xiaona>set http_proxy=https://web-proxy.corp.hp.com:8080/
C:\Users\xiaona>go get -v gopkg.in/fatih/pool.v2
正在获取 https://gopkg.in/fatih/pool.v2?go-get=1
正在解析 https://gopkg.in/fatih/pool.v2?go-get=1 中的元标签(状态码 200)
找到 "gopkg.in/fatih/pool.v2" 的元标签 main.metaImport{Prefix:"gopkg.in/fa
tih/pool.v2", VCS:"git", RepoRoot:"https://gopkg.in/fatih/pool.v2"},位于 https://g
opkg.in/fatih/pool.v2?go-get=1
正在下载 gopkg.in/fatih/pool.v2
gopkg.in/fatih/pool.v2
然后,一切都正常!
<details>
<summary>英文:</summary>
The root cause has been found: Because my computer use a web proxy, so I need to set proxy in environment variable:
C:\Users\xiaona>set https_proxy=https://web-proxy.corp.hp.com:8080/
C:\Users\xiaona>set http_proxy=https://web-proxy.corp.hp.com:8080/
C:\Users\xiaona>go get -v gopkg.in/fatih/pool.v2
Fetching https://gopkg.in/fatih/pool.v2?go-get=1
Parsing meta tags from https://gopkg.in/fatih/pool.v2?go-get=1 (status code 200)
get "gopkg.in/fatih/pool.v2": found meta tag main.metaImport{Prefix:"gopkg.in/fa
tih/pool.v2", VCS:"git", RepoRoot:"https://gopkg.in/fatih/pool.v2"} at https://g
opkg.in/fatih/pool.v2?go-get=1
gopkg.in/fatih/pool.v2 (download)
gopkg.in/fatih/pool.v2
Then, all is OK!
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论