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

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

Why doesn't "go get gopkg.in/..." work while "go get github.com/..." OK?

问题

我尝试使用go get gopkg.in/fatih/pool.v2根据Readme.md安装pool,但无法成功:

  1. C:\Users\xiaona\Documents\GitHub> go get -v gopkg.in/fatih/pool.v2
  2. Fetching https://gopkg.in/fatih/pool.v2?go-get=1
  3. https fetch failed.
  4. Fetching http://gopkg.in/fatih/pool.v2?go-get=1
  5. import "gopkg.in/fatih/pool.v2": http/https fetch: Get http://gopkg.in/fatih/poo
  6. l.v2?go-get=1: dial tcp 107.178.216.236:80: ConnectEx tcp: A connection attempt
  7. failed because the connected party did not properly respond after a period of ti
  8. me, or established connection failed because connected host has failed to respon
  9. d.
  10. package gopkg.in/fatih/pool.v2: unrecognized import path "gopkg.in/fatih/pool.v2
  11. "
  12. Web浏览器中访问`107.178.216.236:80`是可以的。
  13. 我尝试使用`go get github.com/fatih/pool`,它也可以正常工作。
  14. 有人能给出一些关于这个问题的线索吗?
  15. 顺便说一下:我使用的是`Windows PowerShell``git`版本是`1.9.5`
  16. <details>
  17. <summary>英文:</summary>
  18. 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:
  19. C:\Users\xiaona\Documents\GitHub&gt; go get -v gopkg.in/fatih/pool.v2
  20. Fetching https://gopkg.in/fatih/pool.v2?go-get=1
  21. https fetch failed.
  22. Fetching http://gopkg.in/fatih/pool.v2?go-get=1
  23. import &quot;gopkg.in/fatih/pool.v2&quot;: http/https fetch: Get http://gopkg.in/fatih/poo
  24. l.v2?go-get=1: dial tcp 107.178.216.236:80: ConnectEx tcp: A connection attempt
  25. failed because the connected party did not properly respond after a period of ti
  26. me, or established connection failed because connected host has failed to respon
  27. d.
  28. package gopkg.in/fatih/pool.v2: unrecognized import path &quot;gopkg.in/fatih/pool.v2
  29. &quot;
  30. While access `107.178.216.236:80` is OK in web browser.
  31. I try to use `go get github.com/fatih/pool`, and it also works OK.
  32. Could anyone give some clues on this issue?
  33. BTW: I use `windows powershell` and `git` version is `1.9.5`.
  34. </details>
  35. # 答案1
  36. **得分**: 0
  37. 已找到根本原因:因为我的计算机使用了网络代理,所以我需要在环境变量中设置代理:
  38. C:\Users\xiaona&gt;set https_proxy=https://web-proxy.corp.hp.com:8080/
  39. C:\Users\xiaona&gt;set http_proxy=https://web-proxy.corp.hp.com:8080/
  40. C:\Users\xiaona&gt;go get -v gopkg.in/fatih/pool.v2
  41. 正在获取 https://gopkg.in/fatih/pool.v2?go-get=1
  42. 正在解析 https://gopkg.in/fatih/pool.v2?go-get=1 中的元标签(状态码 200)
  43. 找到 "gopkg.in/fatih/pool.v2" 的元标签 main.metaImport{Prefix:"gopkg.in/fa
  44. tih/pool.v2", VCS:"git", RepoRoot:"https://gopkg.in/fatih/pool.v2"},位于 https://g
  45. opkg.in/fatih/pool.v2?go-get=1
  46. 正在下载 gopkg.in/fatih/pool.v2
  47. gopkg.in/fatih/pool.v2
  48. 然后,一切都正常!
  49. <details>
  50. <summary>英文:</summary>
  51. The root cause has been found: Because my computer use a web proxy, so I need to set proxy in environment variable:
  52. C:\Users\xiaona&gt;set https_proxy=https://web-proxy.corp.hp.com:8080/
  53. C:\Users\xiaona&gt;set http_proxy=https://web-proxy.corp.hp.com:8080/
  54. C:\Users\xiaona&gt;go get -v gopkg.in/fatih/pool.v2
  55. Fetching https://gopkg.in/fatih/pool.v2?go-get=1
  56. Parsing meta tags from https://gopkg.in/fatih/pool.v2?go-get=1 (status code 200)
  57. get &quot;gopkg.in/fatih/pool.v2&quot;: found meta tag main.metaImport{Prefix:&quot;gopkg.in/fa
  58. tih/pool.v2&quot;, VCS:&quot;git&quot;, RepoRoot:&quot;https://gopkg.in/fatih/pool.v2&quot;} at https://g
  59. opkg.in/fatih/pool.v2?go-get=1
  60. gopkg.in/fatih/pool.v2 (download)
  61. gopkg.in/fatih/pool.v2
  62. Then, all is OK!
  63. </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:

确定