How to set breakpoints by line number of source file in Delve?

The name says a lot about everything.

The only way I know how to install it is either at runtime or earlier: breakpoint main.main

Is there a way to do this by line number, for example breakpoint ./otherfile.go:200?

+7
source share
2 answers

In your source code

  runtime.Breakpoint()

enter CLI

dlv test

and then

continue

The program will stop at the line of code where you set the breakpoint.

+17
source

The following applies to delve:

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

, , main.go , , , , "" (__ ). :

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

All Articles