Spectrum Chain Development--ide Breakpoint Debugging Introduction
作者:GirpZhang
Experimental environment
Windows10
Go1.9.2.windows-amd64
Visual Studio Code
Git 2.18.0
Need to complete the Visual Studio Code + Golang Development environment configuration
Installing GO1.9.2.WINDOWS-AMD64
Install Git
Install Golang, configure Gopath
本例中使用的 "GOPATH":"E:/GoPath";"GOROOT":"E:/Go"
Install Visual Studio Code, install the Go plugin, and the introduction is Rich Go language support for Visual Studio code
Debug Configuration:
VSCode->查看->调试->添加调试目标,在"没有调试"的下拉框中点击"添加配置.."
To add a target Debug configuration:
{ "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "go", "request": "launch", "mode": "debug", "remotePath": "", "port": 2345, "host": "127.0.0.1", "program": "${fileDirname}", "env": { "GOPATH":"E:/GoPath", "GOROOT":"E:/Go" }, "args": [], "showLog": true } ]}
Download Spectrum Code
git clone git@github.com:SmartMeshFoundation/Spectrum.git
Commissioning Preparation
Create a new multilevel directory under E:/GOPATH/SRC: \github.com\smartmeshfoundation\spectrum
Copy the code from the downloaded spectrum.git to E:/gopath/src/github.com/smartmeshfoundation/spectrum
Open Vscode, select File-open folder, open Spectrum folder
Open Cmd->smc->main.go File
F5 debugging, you will be prompted with the following error:
Failded to continue:"Cannot find Delve debugger. Install from https://github.com/derekparker/delve & ensure it is in your "GOPATH/bin" or "PATH"
Then we use the Go command line to compile the debugger, put the DLV debugger in the Gopath bin directory
go get github.com/derekparker/delve/cmd/dlv
Then you can debug normally, and place breakpoints on the spot where you need to do one step:
Image