Skip to content

Commit

Permalink
Simplify 'NewVersion' a bit (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
VladRassokhin authored Nov 22, 2021
1 parent d7f6c9b commit b991f91
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,14 @@ func newVersion(v string, pattern *regexp.Regexp) (*Version, error) {
}
segmentsStr := strings.Split(matches[1], ".")
segments := make([]int64, len(segmentsStr))
si := 0
for i, str := range segmentsStr {
val, err := strconv.ParseInt(str, 10, 64)
if err != nil {
return nil, fmt.Errorf(
"Error parsing version: %s", err)
}

segments[i] = int64(val)
si++
segments[i] = val
}

// Even though we could support more than three segments, if we
Expand All @@ -92,7 +90,7 @@ func newVersion(v string, pattern *regexp.Regexp) (*Version, error) {
metadata: matches[10],
pre: pre,
segments: segments,
si: si,
si: len(segmentsStr),
original: v,
}, nil
}
Expand Down

0 comments on commit b991f91

Please sign in to comment.