为什么 “go get gopkg.in/…” 不起作用,而 “go get github.com/…” 可以正常工作?

huangapple go评论91阅读模式
英文:

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&#39;t success:  

	C:\Users\xiaona\Documents\GitHub&gt; 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 &quot;gopkg.in/fatih/pool.v2&quot;: 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 &quot;gopkg.in/fatih/pool.v2
	&quot;

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&gt;set https_proxy=https://web-proxy.corp.hp.com:8080/

	C:\Users\xiaona&gt;set http_proxy=https://web-proxy.corp.hp.com:8080/

	C:\Users\xiaona&gt;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&gt;set https_proxy=https://web-proxy.corp.hp.com:8080/

	C:\Users\xiaona&gt;set http_proxy=https://web-proxy.corp.hp.com:8080/

	C:\Users\xiaona&gt;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 &quot;gopkg.in/fatih/pool.v2&quot;: found meta tag main.metaImport{Prefix:&quot;gopkg.in/fa
	tih/pool.v2&quot;, VCS:&quot;git&quot;, RepoRoot:&quot;https://gopkg.in/fatih/pool.v2&quot;} 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>



huangapple
  • 本文由 发表于 2015年6月15日 11:21:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/30836901.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定