下載 golang.org/x 包出錯不用代理的解決辦法


原文鏈接:https://www.jianshu.com/p/6fe61053c8aa?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

原理

  1. 當我們使用 import "golang.org/x/tools/go/buildutil" 導入包時,其實導入的是$GOPATH/src/golang.org/x/tools/go/buildutil目錄的包。

  2. "golang.org/x" 下的包在 "github.com/golang"有鏡像庫。

  3. 所以我們可以從 github.com 上將對應包下載下來放到對應的目錄即可。

實例

比如先切換到 $GOPATH 的 src 目錄,cd $GOPATH/src,然后按需要下載:

  1. git clone --depth 1 https://github.com/golang/tools.git golang.org/x/tools
  2. git clone --depth 1 https://github.com/golang/lint.git golang.org/x/lint
  3. git clone --depth 1 https://github.com/golang/net.git golang.org/x/net
  4. git clone --depth 1 https://github.com/golang/sys.git golang.org/x/sys
  5. git clone --depth 1 https://github.com/golang/crypto.git golang.org/x/crypto
  6. git clone --depth 1 https://github.com/golang/text.git golang.org/x/text
  7. git clone --depth 1 https://github.com/golang/image.git golang.org/x/image
  8. git clone --depth 1 https://github.com/golang/oauth2.git golang.org/x/oauth2


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM