how to debug golang cobra cli app in Goland

716 views Asked by At

how to debug golang cobra cli app in Goland

how to realize it in Goland or i give up by using VScode

2

There are 2 answers

1
kf-jb On

You'll need to either start the debugging session from the IDE or attach he debugger to a running process. You might want to take a look at these article for more details:Starting a new debug session,Attaching to running process

0
Jonathan Ma On

According my understanding, you know how to debug Golang applications which do not involve cobra. For cobra applications, you need to specify the cli arguments in your Run/Debug configurations.

For example, ff you run your application in terminal with the command ./controller daemon -c config.yaml, you will need to add "daemon -c config.yaml" in "Program arguments" field in your Run/Debug configurations.

screenshot