Skip to content

Commit

Permalink
Version check that is go1.21 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Mar 23, 2024
1 parent 92e8e74 commit 1912d77
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
13 changes: 13 additions & 0 deletions cmd/goversion_go122.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build go1.22
// +build go1.22

package cmd

import (
goversion "go/version"
"runtime"
)

func isGoVersionAtLeast(v string) bool {
return goversion.Compare(runtime.Version(), v) < 0
}
8 changes: 8 additions & 0 deletions cmd/goversion_old.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build !go1.22
// +build !go1.22

package cmd

func isGoVersionAtLeast(_ string) bool {
return false
}
5 changes: 2 additions & 3 deletions cmd/main_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"bytes"
goversion "go/version"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -32,8 +31,8 @@ func TestE2E_RerunFails(t *testing.T) {
if testing.Short() {
t.Skip("too slow for short run")
}
if v := runtime.Version(); goversion.Compare(v, "go1.22") < 0 {
t.Skipf("version %v no longer supported by this test", v)
if !isGoVersionAtLeast("go1.22") {
t.Skipf("version %v no longer supported by this test", runtime.Version())
}
t.Setenv("GITHUB_ACTIONS", "no")

Expand Down

0 comments on commit 1912d77

Please sign in to comment.