Vscode go編輯環境
https://studygolang.com/articles/20219
Gopm包下載
原因
在下載包時經常被牆,所以使用 gopm來實現下載。
gopm能實現對go的各種包管理,在國內有加速效果
安裝過程
go get -v -u github.com/gpmgo/gopm
在上述下載gopm時,發現會提示
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
package github.com/gpmgo/gopm: exit status 1
估計是最開始 上面下載vscode插件時,也把這個下載下來了,但是沒有下載成功,然後在 $GOPATH/src/github.com/
下已經存在了 gopm
這個文件夾,現在只要 將它刪除, 然後在該目錄 使用git clone
git clone https://github.com/gpmgo/gopm.git
接下來 又會提示 一個什麼Unknown的包也和剛剛的情況一樣,於是只先進入$GOPATH/src/github.com/Unknwon
刪除掉com目錄,然後重新克隆
git clone https://github.com/unknwon/com.git
接下來再次
go get -v -u github.com/gpmgo/gopm
就能下載完所有包,然後可以看到在 $GOPATH/bin
中多了一個 gopm.exe
使用
gopm help
發現提示 bash: gopm: command not found
應該是需要將其添加到環境變量中,我的解決方法有點暴力,我直接把gopm.exe複製到 $GOROOT/bin
下,然後就可以在任何地方使用了…
通過’gopm get -g xxx’,可以將指定的包下載到GOPATH下。(建議使用)
https://www.jianshu.com/p/db9e6ae0d227
https://www.jianshu.com/p/a7c3aeb0948d