1、go下載安裝並配置環境變數
2、安裝工具:
1)安裝gocode
go get -u -v github.com/nsf/gocode
2)安裝godef
go get -u -v github.com/rogpeppe/godef
3)安裝golint
go get -u -v github.com/golang/lint/golint
4)安裝go-find-references
go get -u -v github.com/lukehoban/go-find-references
5)安裝go-outline
go get -u -v github.com/lukehoban/go-outline
6)安裝goreturns
go get -u -v sourcegraph.com/sqs/goreturns
7)安裝gorename
go get -u -v golang.org/x/tools/cmd/gorename
(3)Visual Studio Code支援Go語言調試執行以下命令:
-
- go get -v -u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv
- brew install go-delve/delve/delve
- go get -v -u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv
修改“dlv-cert”認證
1.開啟“鑰匙串訪問”
2.開啟菜單->鑰匙串訪問->認證助理->建立認證
3.名稱:dIv 身份類型:自我簽署憑證 認證類型:程式碼簽署 並選擇“讓我覆蓋這些預設值”
4.單擊“繼續”,有限期(天數):365,可以自己修改,3650
5.一直繼續,直到看到“指定用於該認證的位置”鑰匙串,選擇“系統”並單擊“建立”按鈕
6.重啟Finder,再開啟“鑰匙串訪問”,選擇“系統”,就會看到建立好的“dlv-cert”認證
7.右鍵"dlv-cert"認證,選擇“顯示簡介->信任->程式碼簽署”修改為:始終信任
8.開啟terminal,進入到之前安裝好的$GOPATH/src
目錄下的dlv源碼檔案目錄:github.com/derekparker/delve
9.輸入如下命令就可以重新編譯出一個帶程式碼簽署的dlv執行程式
GO15VENDOREXPERIMENT=1 CERT=dlv-cert make install
可能會遇到的問題
The execution file "./dlv -h" always return >> killed:9
stackoverflow解決方式:
- I need to do this step below
-
- brew install go-delve/delve/delve
- and go to $GOPATH/src/github.com/derekparker
- git clone https://github.com/derekparker/delve.git
- CERT=dlv-cert make install
- (remove old dlv > brew install delve > codesign dlv)
-
- not just run
- go get github.com/derekparker/delve/cmd/dlv
-
- and it works now.
重啟Visual Studio Code,就可以完美使用了