simplifying if-else chains to switches (#6208)

This commit is contained in:
Oleg Kovalov
2018-08-06 19:26:40 +02:00
committed by kannappanr
parent a82500f162
commit 37de2dbd3b
14 changed files with 120 additions and 138 deletions

View File

@@ -56,11 +56,12 @@ func (bf *BoolFlag) UnmarshalJSON(data []byte) (err error) {
// ParseBoolFlag - parses string into BoolFlag.
func ParseBoolFlag(s string) (bf BoolFlag, err error) {
if s == "on" {
switch s {
case "on":
bf = true
} else if s == "off" {
case "off":
bf = false
} else {
default:
err = fmt.Errorf("invalid value %s for BoolFlag", s)
}