1. 程式人生 > >mac 下vscode 部署go ethereum 過程 注意節點

mac 下vscode 部署go ethereum 過程 注意節點

1)安裝go 1.76

    a.環境變數設定很重要:

export GOROOT=/usr/local/go

export GOBIN=$GOROOT/bin

export GOARCH=amd64

export GOOS=darwin

export GOPATH=../GO

export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:/usr/local/go/bin:/usr/local/bin

  b.{gopath}  目錄結構

    bin

    pkg

    src

  c.讓當前mac使用者可以 管理/usr/local/go 目錄很重要,命令為:

sudo -i

Password:

chown -R {user} /usr/local/go

d.go 外掛安裝

  • gocode: go get -u -v github.com/nsf/gocode
  • godef: go get -u -v github.com/rogpeppe/godef
  • golint: go get -u -v github.com/golang/lint/golint
  • go-outline: go get -u -v github.com/lukehoban/go-outline
  • goreturns: go get -u -v sourcegraph.com/sqs/goreturns
  • gorename: go get -u -v golang.org/x/tools/cmd/gorename
  • gopkgs: go get -u -v github.com/tpng/gopkgs
  • go-symbols: go get -u -v github.com/newhook/go-symbols
  • guru: go get -u -v golang.org/x/tools/cmd/guru

部分元件安裝下載不了,需要翻牆執行

除錯外掛安裝

安裝 homebrew https://brew.sh/

$ brew install go-delve/delve/delve

$go get -v -u github.com/derekparker/delve/cmd/dlv 再執行一遍


2)安裝vscode 1.151

    vscode環境變數user settings

{ "workbench.colorTheme": "Visual Studio Light", "files.autoSave": "onFocusChange", "go.gopath": "../GO", "go.goroot": "/usr/local/go", "go.toolsGopath": "../GO" } 除錯環境變數launch.json { "version": "0.2.0", "configurations": [ { "name": "Phantom", "type": "go", "request": "launch", "mode": "debug", "remotePath": "", "port": 1234, "host": "127.0.0.1", "program": "${file}", //除錯當前檔案 "env": {"QUICKPAY_ENV":"testing"}, "args": [], "showLog": true } ] }

3)下載go ethereum 1.6.7版本,原始碼拷貝程式碼到{gopath}/src/github.com/ethereum/go-ethereum 目錄下

4)ok