Skip to content

Commit 5e1a39d

Browse files
authored
internal/flags: fix "flag redefined" bug for alias on custom flags (#30796)
This change fixes a bug on the `DirectoryFlag` and the `BigFlag`, which would trigger a `panic` with the message "flag redefined" in case an alias was added to such a flag.
1 parent 6485d5e commit 5e1a39d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/flags/flags.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (f *DirectoryFlag) Apply(set *flag.FlagSet) error {
9090
}
9191
}
9292
eachName(f, func(name string) {
93-
set.Var(&f.Value, f.Name, f.Usage)
93+
set.Var(&f.Value, name, f.Usage)
9494
})
9595
return nil
9696
}
@@ -172,7 +172,7 @@ func (f *BigFlag) Apply(set *flag.FlagSet) error {
172172
}
173173
eachName(f, func(name string) {
174174
f.Value = new(big.Int)
175-
set.Var((*bigValue)(f.Value), f.Name, f.Usage)
175+
set.Var((*bigValue)(f.Value), name, f.Usage)
176176
})
177177
return nil
178178
}

0 commit comments

Comments
 (0)