In GDB, there is a flag --init-command
which I can define a command like b dbConnection
and it will be applied automatically after running the project. It sets the breakpoint on the dbConnection
function.
I was looking for the same in Delve but I couldn't find it.
The whole idea is instead of running dlv command and then telling where is my function and set the breakpoint there, I wanna give the function name before running dlv as init command like break pkg/db/connection.go:dbConnection
. I can run fzf command to find the file easily and then I'll pass it to the dlv init command to set the breakpoint there.
CodePudding user response:
Here is the answer https://github.com/go-delve/delve/discussions/3189
The flag is --init
. For example:
dlv debug --init <(echo b main.main)