Currently, The version of the cmd tool is set using an additional function which can be seen here.
The Cobra Library already has a feature to set the version using the underlying struct field Version.
// Version defines the version for this command. If this value is non-empty and the command does not
// define a "version" flag, a "version" boolean flag will be added to the command and, if specified,
// will print content of the "Version" variable. A shorthand "v" flag will also be added if the
// command does not define one.
Currently, The version of the cmd tool is set using an additional function which can be seen here.
The Cobra Library already has a feature to set the version using the underlying struct field
Version
.My proposal to improve it :
I have already tested it and working as expected. Please check the output below: