mirror of
https://github.com/golang/go
synced 2024-11-18 15:54:42 -07:00
flag: Check for Set error
Check for Set error when a boolean flag isn't explicitly given a value. Fixes #9345 Change-Id: I97a1289f8cf27567d1a726ebe5ef167c800f357c Reviewed-on: https://go-review.googlesource.com/1897 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
e4c2229e4c
commit
bc611a31a5
@ -767,7 +767,9 @@ func (f *FlagSet) parseOne() (bool, error) {
|
|||||||
return false, f.failf("invalid boolean value %q for -%s: %v", value, name, err)
|
return false, f.failf("invalid boolean value %q for -%s: %v", value, name, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fv.Set("true")
|
if err := fv.Set("true"); err != nil {
|
||||||
|
return false, f.failf("invalid boolean flag %s: %v", name, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// It must have a value, which might be the next argument.
|
// It must have a value, which might be the next argument.
|
||||||
|
Loading…
Reference in New Issue
Block a user