Skip to content

Commit

Permalink
return errors in Get method of version type
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Meinhardt committed Mar 19, 2019
1 parent 2ce0578 commit 6f18f9e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,26 @@ func (v *version) Get(vt string) (string, error) {

numbers := strings.Split(v.current, ".")

var err error
switch versionType {
case MAJOR:
major, _ := strconv.Atoi(numbers[0])
major, e := strconv.Atoi(numbers[0])
err = e
numbers[0] = strconv.Itoa(major + 1)
numbers[1] = "0"
numbers[2] = "0"
case MINOR:
minor, _ := strconv.Atoi(numbers[1])
minor, e := strconv.Atoi(numbers[1])
err = e
numbers[1] = strconv.Itoa(minor + 1)
numbers[2] = "0"
case PATCH:
patch, _ := strconv.Atoi(numbers[2])
patch, e := strconv.Atoi(numbers[2])
err = e
numbers[2] = strconv.Itoa(patch + 1)
}

return strings.Join(numbers, "."), nil
return strings.Join(numbers, "."), err
}

func (v *version) SetNext(vt string) (string, error) {
Expand Down

0 comments on commit 6f18f9e

Please sign in to comment.