Search code examples
gocommandgo-cobra

Link another Golang Cobra CLI to current Golang Cobra CLI


I am working on a new Golang Cobra CLI, which handles several commands. I later on found out that there is already an existing Golang Cobra CLI that handles some commands that I will be covering in the new CLI, but not all. In other words, my new CLI cover all commands of the existing CLI with some extra commands.

Is it possible for us to link the existing CLI into the new CLI?

Note: I am not sure whether "link" is the best word to describe what I am interested to do. In case this is already answered before on SA, feel free to mark this as duplicate.


Solution

  • I think your best bet is to fork the other repo with fewer commands, then edit it to add your commands. Assuming that both repos are open source.

    If your code is closed-source then you can bring in their repo as a dependency.