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

benbot picture benbot · Mar 8, 2016 · Viewed 7.4k times · Source

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?

Answer

Alejandro Serret picture Alejandro Serret · Feb 21, 2017

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.