Delve aims to be a very simple and powerful tool, but can be confusing if you are not used to using a source level debugger in a compiled language. Tracking down bugs in your code can be a very frustrating experience. This is even more true of highly parallel code. Having a good debugger at your disposal can make all the difference when it comes to tracking down a difficult, or hand to reproduce bug in your code.
Implementation
I am using go version go1.8 windows/amd64. (Delve debugger can run in Linux, Windows and macOS.
Let's create a simple code in golang to demonstrate Delve debugger. The code shown as below:
filename: main.go
package main
import "fmt"
func main() {
fmt.Println("Hello World")
fmt.Println("Hello World")
fmt.Println("Hello World")
}
Open your windows command prompt to perform Delve debugger by pressing Windows Key + R and type cmd then press enter. In command prompt, type command
dlv debug main.go
Then you will enter to dlv debug mode
to check delve command you can type help and it will shown all command that can be used for debugging
Let's add break-point at line 6 by using command
break main.go:6
add break-point at line 7 by using command
break main.go:7
Then you can start debug by using command
continue
and it will stop at break-point line 6
if you want to continue to the next break point, just using command
next
and it will go to the next break-point line 7
You can see the break-point with simbol => (blue color) it's in yellow box
command is in red box and output is in green box, shown as picture below
I think that's all. Thank you
Other topics:
How to build NGINX RTMP module, Setup Live Streaming with NGINX RTMP module, Publishing Stream with Open Broadcaster Software (OBS), Create Adaptive Streaming with NGINX RTMP, Implementing Filtergraph in Streaming with NGINX RTMP, How to Implement Running Text in Streaming with NGINX RTMP, How to build OpenSceneGraph with Code::Blocks, How to build OpenSceneGraph with Visual Studio 2010, Building Geometry Model, How to run OpenSceneGraph with Netbean IDE 8.2 C++, Rendering Basic Shapes, Using OSG Node to Load 3D Object Model, Rendering 3D Simulator with OpenSceneGraph, How to compile wxWidgets with Visual Studio 2010, How to Setup Debugging in Golang with Visual Code, How to Load 3D Object Model with OpenSceneGraph on wxWidgets
Thank you for sharing this! What you have shared is very helpful and informative. Would love to see more updates from you.
ReplyDeleteWebsite Development