Skip to content

Commit

Permalink
added conditional check to support 'make goimports' for go version < …
Browse files Browse the repository at this point in the history
…1.16
  • Loading branch information
Renu authored and Renu committed Dec 30, 2024
1 parent 16fe7e4 commit 58839c2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 58839c2

Please sign in to comment.