Skip to content

Commit

Permalink
fix: fixes go version parsing. (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcchavezs authored Oct 11, 2022
1 parent 664d41f commit 12b7087
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,18 @@ func checkGoVersion() error {
return fmt.Errorf("unexpected go error: %v", err)
}

versionRegex := regexp.MustCompile("go([0-9]+).([0-9]+).([0-9]+)")
// Version can/cannot include patch version e.g.
// - go version go1.19 darwin/arm64
// - go version go1.19.2 darwin/amd64
versionRegex := regexp.MustCompile("go([0-9]+).([0-9]+).?([0-9]+)?")
compare := versionRegex.FindStringSubmatch(v)
if len(compare) != 4 {
return fmt.Errorf("unexpected go semver: %q", v)
}
compare = compare[1:]
if compare[2] == "" {
compare[2] = "0"
}

base := strings.SplitN(minGoVersion, ".", 3)
if len(base) == 2 {
Expand Down

0 comments on commit 12b7087

Please sign in to comment.