Golang delve: Difference between revisions
From wikinotes
No edit summary |
|||
Line 8: | Line 8: | ||
|- | |- | ||
| github || https://github.com/go-delve/delve | | github || https://github.com/go-delve/delve | ||
|- | |||
| command docs || https://github.com/go-delve/delve/blob/master/Documentation/cli/README.md | |||
|- | |||
| editor plugins || https://github.com/go-delve/delve/blob/master/Documentation/EditorIntegration.md | |||
|- | |- | ||
|} | |} |
Revision as of 16:52, 26 June 2022
delve is a go debugger.
It is more knowledgeable about the go runtime than golang gdb .
There are also editor integrations.
Documentation
Install
go install github.com/go-delve/delve/cmd/dlv@latest
Usage
Delve builds your executable automatically with flags required for it to debug your program.
# start debugger dlv debug [example.com/x/foo/package] [-- [--your-params]] # run program dlv test [example.com/x/foo/package] # run testsAdd your breakpoints, then continue to execute your program
b main.main # add breakpoint to 'main.go's 'main' method b main.go:10 # add breakpoint to 'main.go's line 10 c # continue (start executing)Inspect your program, learn
p yourVar # print var l # print location n # next line (enters loop, not skip to end) s # step into line <enter> # repeat last command