如何在Delve中通过源文件行号设置断点?

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?

In your Source code type

  runtime.Breakpoint()

type in the CLI

dlv test

and then

continue

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

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