If you want to run a single unit test in the Delve debugger for Go, here’s how you do it on the command line:
dlv test github.com/path/to/package/testsuite -- -test.run ^Test_Random$
The command is run from within
path/to/package/testsuite - the start point for the debugger will be the
Once the debugger builds the test binary and launches, you can set breakpoints relative to the start of the function. For example:
b TestRandom:5 sets a breakpoint on the 5th line of the function.
I’m fairly new to Go, and debugging from witin the go-vim plugin allows the same functionality using the
:GoDebugTestFunc command with the cursor on the required function.
So far, I prefer multiplexing with Tmux, with my code in Vim in one pane and the debugger in the other.
comments powered by Disqus