Simplify sub-command initialization w/o IgnoreDefault

This commit is contained in:
Sebastiaan Pasterkamp 2022-06-05 17:54:46 +02:00
parent a87d80089a
commit b48371a62f
1 changed files with 1 additions and 1 deletions

View File

@ -531,7 +531,7 @@ func (p *Parser) process(args []string) error {
// instantiate the field to point to a new struct
v := p.val(subcmd.dest)
if !p.config.IgnoreDefault || v.IsNil() {
if v.IsNil() {
v.Set(reflect.New(v.Type().Elem())) // we already checked that all subcommands are struct pointers
}