From the course: Debugging in Go
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Test: Debugging test code - Go Tutorial
From the course: Debugging in Go
Test: Debugging test code
- [Instructor] The final dlv subcommand that we're going to learn in order to start a new debugging session is the test subcommand. The test subcommand allows you to start a debugging session using the test that you've written for your code. This is extremely useful if you want to exercise a bug that is triggered by a specific test or if the package that you're working on is not a main package and there is no main package within your project, perhaps it's just a library or something like that. In that case, you won't have an actual executable that you can run and debug. To get around that, you can debug your program using the dlv test command, which works somewhat similar to the go test subcommand. In order to debug our test, all we have to do is at the command line, we simply write dlv test. This is just like you would write go test, except for you replace go with dlv. Hitting Enter here, as always, we're greeted with the same debug session startup prompt, and we can start issuing…