diff --git a/cmd/goversion_go122.go b/cmd/goversion_go122.go new file mode 100644 index 0000000..704e3f1 --- /dev/null +++ b/cmd/goversion_go122.go @@ -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 +} diff --git a/cmd/goversion_old.go b/cmd/goversion_old.go new file mode 100644 index 0000000..06f548a --- /dev/null +++ b/cmd/goversion_old.go @@ -0,0 +1,8 @@ +//go:build !go1.22 +// +build !go1.22 + +package cmd + +func isGoVersionAtLeast(_ string) bool { + return false +} diff --git a/cmd/main_e2e_test.go b/cmd/main_e2e_test.go index 8586b38..bbdaa1d 100644 --- a/cmd/main_e2e_test.go +++ b/cmd/main_e2e_test.go @@ -2,7 +2,6 @@ package cmd import ( "bytes" - goversion "go/version" "io/ioutil" "os" "path/filepath" @@ -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")