From 598563695a1bffaea9378c2eb92921a8fa9ea490 Mon Sep 17 00:00:00 2001 From: Tom Czarniecki Date: Mon, 14 Jun 2021 06:58:55 +1000 Subject: [PATCH] add staticcheck linter --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bb4f590..dac3f31 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ LDFLAGS := -X github.com/tomcz/openldap_exporter.commit=${GITCOMMIT} LDFLAGS := ${LDFLAGS} -X github.com/tomcz/openldap_exporter.tag=${GIT_TAG} .PHONY: precommit -precommit: clean format build +precommit: clean format lint build .PHONY: commit commit: clean @@ -26,6 +26,14 @@ endif @echo "Running goimports ..." @goimports -w -local github.com/tomcz/openldap_exporter $(shell find . -type f -name '*.go' | grep -v '/vendor/') +.PHONY: lint +lint: +ifeq (, $(shell which staticcheck)) + go install honnef.co/go/tools/cmd/staticcheck@2021.1 +endif + @echo "Running staticcheck ..." + @staticcheck $(shell go list ./... | grep -v /vendor/) + compile = GOOS=$1 GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o target/openldap_exporter-$1 ./cmd/openldap_exporter .PHONY: build