go-arg
go-arg copied to clipboard
pointer-embedded fields are not supported
I was doing some lovely refactoring and I was able to take my main tool's config struct, separate it out, decorate it with the arg
struct tags, and then embed it both in my main struct and also in a new struct which also included some fields for sub commands.
I then got the following error:
RunArgs.Config: *lib.Config fields are not supported
The struct looks approximately like this:
type RunArgs struct {
*lib.Config // embedded config XXX: this line breaks things!
RunEmpty *cliUtil.EmptyArgs `arg:"subcommand:empty" help:"run empty payload"`
RunLang *cliUtil.LangArgs `arg:"subcommand:lang" help:"run lang (mcl) payload"`
}
In the lib package:
type Config struct {
// Program is the name of this program, usually set at compile time.
Program string
// Version is the version of this program, usually set at compile time.
Version string
Hostname *string `arg:"--hostname" help:"hostname to use"`
// ...
}
It seems we don't support the embedded struct? Either this is a "feature we need to add" or there's some gotcha I don't know about. In either case, I'd appreciate your feedback, and would appreciate a patch even more!