Golang.org/x目錄被Blocked的解決方案
在Go開發中,經常有大量專案依賴golang.org/x包,但這個原始碼包被儲放在萬惡的國外資本勢力的伺服器上,國內開發人員想要使用需要一翻動作。
golang團隊將他們的程式碼映象在Github上,因此,我們可以將golang.org/x使用到的包,統統下載在我們開發環境的$GOPATH/src/golang.org/x
目錄,編譯專案時就可以直接使用本地依賴。
首先,在 $GOPATH 目錄中建立 golang.org/x 目錄:
$ mkdir -p $GOPATH/src/golang.org/x
然後把x
的幾個包clone下來:
$ cd $GOPATH/src/golang.org/x # Clone 常用和幾個庫: $ git clone --depth=1 https://github.com/golang/tools.git $ git clone --depth=1 https://github.com/golang/sys.git $ git clone --depth=1 https://github.com/golang/crypto.git $ git clone --depth=1 https://github.com/golang/text.git $ git clone --depth=1 https://github.com/golang/net.git
其它庫以相同方式處理。