0

how to debug golang cobra cli app in Goland

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

Amila Senadheera
  • 12,229
  • 15
  • 27
  • 43
hero
  • 11
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Feb 21 '23 at 02:11
  • Please don't post pictures of text. Include the actual code or output in your question, formatted as a code sample. There is formatting help available in the editor. – larsks Feb 21 '23 at 02:20

2 Answers2

0

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

kf-jb
  • 51
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 27 '23 at 09:07
0

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

Jonathan Ma
  • 451
  • 4
  • 6