From cca5336a8a78698f7c75df3b8e42349f38e15564 Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751NSS@gmail.com> Date: Tue, 16 Apr 2024 00:05:30 +0800 Subject: [PATCH] feat: optimize go version auto set (#2182) --- scripts/make-rules/golang.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk index 5a5d1a788..d6de8e346 100644 --- a/scripts/make-rules/golang.mk +++ b/scripts/make-rules/golang.mk @@ -17,7 +17,7 @@ # GO := go -GO_SUPPORTED_VERSIONS ?= 1.19|1.20|1.21|1.22|1.23 +GO_MINIMUM_VERSION ?= 1.19 GO_LDFLAGS += -X $(VERSION_PACKAGE).gitVersion=$(GIT_TAG) \ -X $(VERSION_PACKAGE).gitCommit=$(GIT_COMMIT) \ @@ -132,8 +132,8 @@ go.versionchecker: ## go.build.verify: Verify that a suitable version of Go exists .PHONY: go.build.verify go.build.verify: -ifneq ($(shell $(GO) version | grep -q -E '\bgo($(GO_SUPPORTED_VERSIONS))\b' && echo 0 || echo 1), 0) - $(error unsupported go version. Please make install one of the following supported version: '$(GO_SUPPORTED_VERSIONS)') +ifneq ($(shell $(GO) version|awk -v min=$(GO_MINIMUM_VERSION) '{gsub(/go/,"",$$3);if($$3 >= min){print 0}else{print 1}}'), 0) + $(error unsupported go version. Please install a go version which is greater than or equal to '$(GO_MINIMUM_VERSION)') endif ## go.build.%: Build binaries for a specific platform