Go安裝一些第三方庫

原文連接:https://javasgl.github.io/go-get-golang-x-packages/ 侵權聯繫刪除!php

go在go get 一些 package時候的會因爲衆所周知的緣由而沒法下載。好比在安裝 bee的時候有可能會遇到沒法下載 golang.org/x/sys/unix 的問題。java

unrecognized import path "golang.org/x/sys/unix"
  • 1

解決方案:手動從github下載相應的packagegit

git clone --depth=1 https://github.com/golang/xxx.git git clone --depth=1 https://github.com/golang/xxx.git
  • 1
  • 2

注:xxx 爲對應的須要的庫github

舉例:這裏要下載golang.org/x/sys/unix, 對應到github地址爲:github.com/golang/sys.git 。golang

下載完成後,軟鏈或者複製 到 $GOPATH/src/golang.org/x/ 下便可。ui

如: $ mv sys ~/go/src/golang.org/x/spa

golang.org/
└── x
    ├── net
    ├── sys
    └── tools
4 directories

更爲簡便的方法:unix

mkdir -p $GOPATH/src/golang.org/x/ cd !$ git clone https://github.com/golang/net.git git clone https://github.com/golang/sys.git git clone https://github.com/golang/tools.git
相關文章
相關標籤/搜索