fix RegisterFlagCompletionFunc concurrent map writes error (#1423)

* fix-RegisterFlagCompletionFunc-concurrent
* set to root command
* move to non-public fields
This commit is contained in:
silenceshell
2021-07-01 05:49:30 +08:00
committed by GitHub
parent 2dea4f2ef3
commit 3c8a19ecd3
3 changed files with 12 additions and 7 deletions

View File

@ -142,6 +142,9 @@ type Command struct {
// that we can use on every pflag set and children commands
globNormFunc func(f *flag.FlagSet, name string) flag.NormalizedName
//flagCompletionFunctions is map of flag completion functions.
flagCompletionFunctions map[*flag.Flag]func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)
// usageFunc is usage func defined by user.
usageFunc func(*Command) error
// usageTemplate is usage template defined by user.