use strings.Join
This commit is contained in:
parent
cdc7af744e
commit
01d5cfab70
12
context.go
12
context.go
@ -308,16 +308,8 @@ func checkRequiredFlags(flags []Flag, set *flag.FlagSet) error {
|
||||
return fmt.Errorf("Required flag %q not set", missingFlags[0])
|
||||
}
|
||||
if numberOfMissingFlags >= 2 {
|
||||
var missingFlagsOutput string
|
||||
for idx, f := range missingFlags {
|
||||
// if not the last item, append with a ", "
|
||||
if idx != numberOfMissingFlags-1 {
|
||||
missingFlagsOutput = fmt.Sprintf("%s%s, ", missingFlagsOutput, f)
|
||||
} else {
|
||||
missingFlagsOutput = fmt.Sprintf("%s%s", missingFlagsOutput, f)
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("Required flags %q not set", missingFlagsOutput)
|
||||
joinedMissingFlags := strings.Join(missingFlags, ", ")
|
||||
return fmt.Errorf("Required flags %q not set", joinedMissingFlags)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user