How do you debug a Go program with Delve (dlv)? How do you attach to a running process, debug a test, and debug goroutines?
Question 564MediumGo 1.22 to 1.25
Delve is the Go debugger. It understands goroutines, the Go scheduler and Go types better than gdb does. The main entry points are:
# build and debug the main package (Delve turns optimizations off for you)
dlv debug ./cmd/api -- -config=dev.yaml
# debug the tests of one package, running only one test
dlv test ./internal/store -- -test.run '^TestUpsert