Spectrum Chain Development — IDE Breakpoint Debugging
Sep 6, 2018 · 2 min read
This article introduces the breakpoint debugging section of the Spectrum chain development.
The development environment
- Windows10
- go1.9.2.windows-amd64
- Visual Studio Code
- Git 2.18.0
You need complete Visual Studio Code + GoLang development environment configuration
- Install go1.9.2.windows-amd64,Deploy GOPATH
- Install Git
- Install Visual Studio Code,Install Go plug-in,Is introduced in the Rich Go language support for Visual Studio Code
In this example, "GOPATH":"E:/GoPath";"GOROOT":"E:/Go"
- Debug configuration:
VSCode->view->debug->Add debug target,In the “no debugging” drop-down box, click “add configuration.. “Add 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 } ] }Clone Spectrum Code:
git clone git@github.com:SmartMeshFoundation/Spectrum.gitDebugging preparation:
- Create new multilevel directory in E:/GoPath/src :\github.com\SmartMeshFoundation\Spectrum
- Copy the downloaded code in Spectrum.git to /GoPath/src/github.com/SmartMeshFoundation/Spectrum folder

- Open VSCode,Select file->open folder ->open Spectrum folder
- open cmd folder->smc folder->main.go file,like:

- F5 debug,The following error will be prompted:
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 used the Go command line to compile the debugger and put the dlv debugger under GOPATH’s bin directory:
- Use the cmd command line to enter directory E:\GoPath\bin
- Execute the command to install the dlv
go get github.com/derekparker/delve/cmd/dlv
- After the installation is completed, it can be debugged normally. The breakpoint is placed where required for one-step debugging:

