Skip to content

Commit

Permalink
Simplify parseSegment
Browse files Browse the repository at this point in the history
  • Loading branch information
lesiw committed Sep 3, 2023
1 parent 8de2106 commit 1c71a86
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions bump.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ func run() int {
func parseSegment(s string) (int, error) {
if s == "" {
return -1, nil
} else {
var err error
ret, err := strconv.Atoi(s)
if err != nil {
switch s {
case "major":
return 0, nil
case "minor":
return 1, nil
case "patch":
return 2, nil
default:
return 0, fmt.Errorf("unrecognized segment: '%s'\n", s)
}
}

ret, err := strconv.Atoi(s)
if err != nil {
switch s {
case "major":
return 0, nil
case "minor":
return 1, nil
case "patch":
return 2, nil
default:
return 0, fmt.Errorf("unrecognized segment: '%s'\n", s)
}
return ret, nil
}

return ret, nil
}

func readInput(reader io.Reader) (string, error) {
Expand Down

0 comments on commit 1c71a86

Please sign in to comment.