From 58839c2efbe821d82500f24bd2dbbe927543064e Mon Sep 17 00:00:00 2001 From: Renu Date: Mon, 30 Dec 2024 17:41:03 +0530 Subject: [PATCH] added conditional check to support 'make goimports' for go version < 1.16 --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 4810773aa6c..07419550bc8 100644 --- a/Makefile +++ b/Makefile @@ -178,9 +178,17 @@ golangci-lint: | $(GOLANGCILINT) ; $(info $(M) running golangci-lint…) @ ## Ru golangci-lint-check: | $(GOLANGCILINT) ; $(info $(M) Testing if golint has been done…) @ ## Run golangci-lint for build tests CI job $Q $(GOLANGCILINT) run -j 1 --color=never +GO_VERSION := $(shell go version | awk '{print $$3}' | sed 's/go//') +GO_OLD_VERSION := $(shell [ "$(GO_VERSION)" \< "1.16" ] && echo 1 || echo 0) + GOIMPORTS = $(BIN)/goimports +ifeq ($(GO_OLD_VERSION),1) +$(BIN)/goimports: PACKAGE=golang.org/x/tools/cmd/goimports +else $(BIN)/goimports: | $(BIN) ; $(info $(M) building goimports…) GOBIN=$(BIN) go install golang.org/x/tools/cmd/goimports@latest +endif + .PHONY: goimports goimports: | $(GOIMPORTS) ; $(info $(M) running goimports…) ## Run goimports