This guide assumes you are using Delve to debug your Go code
- List available commands from the debugger:
help(abbrh)
- From the current directory's package:
$ dlv debug - From a specific package:
$ dlv debug <package>
$ dlv attach <pid>
💡 The following commands pertain to the debugger when a breakpoint is met or code is paused
- Set a breakpoint on the current line:
break +0(abbrb +0) - Set a breakpoint on line_number in the current file:
break <line_number>(abbrb <line_number>) - Set a breakpoint on line_number in file_name:
break <file_name>:<line_number>(abbrb <file_name>:<line_number>) - List all breakpoints:
breakpoints(abbrbp) - Remove a breakpoint:
clear <breakpoint_id> - Remove all breakpoints:
clearall
💡 The following commands pertain to the debugger when a breakpoint is met or code is paused
- Continue until next breakpoint:
continue(abbrc) - Step to the next statement in the current function:
next(abbrn) - Step in to the next statement or into the next function:
step(abbrs) - Step out of the current function on the stack:
stepout
💡 The following commands pertain to the debugger when a breakpoint is met or code is paused
- List the current source and line_count before and after:
list(abbrl) - Run an expression in the current context:
print <expr>(abbrp <expr>) - Show the current stacktrace:
stack(abbrbt) - List all local variables:
locals - Search all local variables:
locals <search_regex> - Show detailed information for a local var:
locals -v <search_regex> - Print local variable data:
print <local_variable_name>(abbrp <local_variable_name>)
- Stop debugging:
exit(abbrq)