Cobra and Persistentflags gotchas

If you are using cobra cmd line library for golang applications and it’s PersistentFlags and if you have a use case where you are adding same kind of flag in multiple places. You might burn your fingers in that case, if you keep adding it in multiple sub-commands without giving it a second thought. To understand what is really happening and why it is happening follow along. All the code referenced here can be found here https://github.com/surajssd/cobrademo. ...

January 4, 2019 · 3 min · Suraj Deshmukh