How can I set breakpoints by the sourcefile line number in Delve?

Viewed 9566

The title pretty much says it all.

The only way I know how to set one is either during the runtime of the program or just before with breakpoint main.main

Is there a way I can do this by line number like breakpoint ./otherfile.go:200?

2 Answers

The following is valid in delve:

(dlv) break <breakpoint_name> <filename_pattern>:<line_number>

If you have ambiguous filenames, say main.go spread all over your sources and possibly vendor directory, just make you make it look "unique" to delve (filename_pattern is not your exact file location). For example:

(dlv) break myLoopingStuff project_name/loops.go:30
(dlv) condition myLoopingStuff thing == someOther.thing
Related