From d4980a0e4d582775b318062c0446e59fb1cfca2a Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 28 Oct 2018 09:59:23 +0800 Subject: [PATCH] :bug: Fix #349 --- util/go_test.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/util/go_test.go b/util/go_test.go index bb4c9d2..2e75673 100644 --- a/util/go_test.go +++ b/util/go_test.go @@ -16,9 +16,10 @@ package util import ( "runtime" - "strconv" "strings" "testing" + + "github.com/hashicorp/go-version" ) func TestGetCrossPlatforms(t *testing.T) { @@ -33,17 +34,27 @@ func TestGetAPIPath(t *testing.T) { apiPath := Go.GetAPIPath() v := runtime.Version()[2:] - v = v[:3] - - verNum, err := strconv.ParseFloat(v, 64) + if 3 < len(v) { + v = v[:4] + } else { + v = v[:3] + } + ver, err := version.NewVersion(v) if nil != err { t.Error(err) return } - if verNum >= 1.4 { + constraints, err := version.NewConstraint(">= 1.4") + if nil != err { + t.Error(err) + + return + } + + if constraints.Check(ver) { if !strings.HasSuffix(apiPath, "src") { t.Error("api path should end with \"src\"")