Home >Backend Development >Golang >Debugging golang framework using breakpoints and monitors
By using breakpoints and monitors, you can have an in-depth understanding of the code execution of the Go framework: set breakpoints to pause the program at specific lines; create monitors to monitor the value of variables or expressions in real time; practice case: use in gin Breakpoints and monitors debug the route and monitor the value of the context variable c.
Debugging the Go framework through breakpoints and monitors
When debugging the Go framework, you can use breakpoints and monitors to Gain insight into how your code is executing. This article will guide you on how to set up and use these debugging tools.
Breakpoints
Breakpoints allow you to pause your program when code execution reaches a specific line. To set a breakpoint, go to the line in Visual Studio Code and click the gray area next to the line number. You can also use the keyboard shortcut F9.
Monitor
Monitor allows you to monitor the value of a variable or expression in real time. To create a monitor, click the View menu in the debugger view and select Monitor. In the Watch window, enter the name of the variable or expression.
Practical case
The following is how to use breakpoints and monitors to debug routing in gin:
/ Set a breakpoint in api/users
route handler. /api/users
URL in your browser. c
to monitor the current value of the context. c
changes. Tip
The above is the detailed content of Debugging golang framework using breakpoints and monitors. For more information, please follow other related articles on the PHP Chinese website!