From 7f96e9f47a96c1432191bd406eb5f6c354d340c6 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Fri, 18 Oct 2024 11:41:35 -0700 Subject: [PATCH] goenv: remove WantGoVersion --- goenv/version.go | 10 ---------- goenv/version_test.go | 30 ------------------------------ 2 files changed, 40 deletions(-) diff --git a/goenv/version.go b/goenv/version.go index 0b608c78..9cc46340 100644 --- a/goenv/version.go +++ b/goenv/version.go @@ -68,16 +68,6 @@ func Parse(version string) (major, minor, patch int, err error) { return major, minor, patch, nil } -// WantGoVersion returns true if Go version s is >= major and minor. -// Returns false if s is not a valid Go version string. See [Parse] for more information. -func WantGoVersion(s string, major, minor int) bool { - ma, mi, _, err := Parse(s) - if err != nil { - return false - } - return ma > major || (ma == major && mi >= minor) -} - // Compare compares two Go version strings. // The result will be 0 if a == b, -1 if a < b, and +1 if a > b. // If either a or b is not a valid Go version, it is treated as "go0.0" diff --git a/goenv/version_test.go b/goenv/version_test.go index 1c60c4f8..1744d2b2 100644 --- a/goenv/version_test.go +++ b/goenv/version_test.go @@ -39,36 +39,6 @@ func TestParse(t *testing.T) { } } -func TestWantGoVersion(t *testing.T) { - tests := []struct { - v string - major int - minor int - want bool - }{ - {"", 0, 0, false}, - {"go", 0, 0, false}, - {"go1", 0, 0, false}, - {"go.0", 0, 0, false}, - {"go1.0", 1, 0, true}, - {"go1.1", 1, 1, true}, - {"go1.23", 1, 23, true}, - {"go1.23.5", 1, 23, true}, - {"go1.23.5-rc6", 1, 23, true}, - {"go2.0", 1, 23, true}, - {"go2.0", 2, 0, true}, - } - for _, tt := range tests { - t.Run(tt.v, func(t *testing.T) { - got := WantGoVersion(tt.v, tt.major, tt.minor) - if got != tt.want { - t.Errorf("WantGoVersion(%q, %d, %d): expected %t; got %t", - tt.v, tt.major, tt.minor, tt.want, got) - } - }) - } -} - func TestCompare(t *testing.T) { tests := []struct { a string