Hello, am new here and also in Go. So am working on a package that would need the user to generate configuration files after pulling the package. Basically i want the user to run a command like packageName init config
then this would create a configuration file within the working directory therefore the user can edit the config file.
Thanks in advance
I know Cobra, but what am trying to achieve is my package having its own commands the way Cobra has cobra init
so i want my package to do the same like running packageName init app
after pulling the package with go get
So their page says you write commands like this:
mkdir -p newApp && cd newApp
cobra init --pkg-name github.com/spf13/newApp
cobra add serve
cobra add config
cobra add create -p 'configCmd'
And then you’ll be able to run your program like:
go build newApp
newApp serve
newApp config create
You can then add flags or positional arguments to the subcommands. This sounds to me like what you’re looking for.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.