Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
export CGO_ENABLED=0
export GO111MODULE=on

LDFLAGS := -w -s
BIN := kosli
LDFLAGS := -w -s
BIN := kosli
GO_VERSION := $(shell awk '/^go /{print $$2}' go.mod)

GIT_COMMIT = $(shell git rev-parse HEAD)
GIT_SHA = $(shell git rev-parse --short HEAD)
Expand Down Expand Up @@ -53,7 +54,20 @@ fmt: ## Reformat package sources
@go fmt ./...

ensure_golangci-lint:
@HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade golangci-lint
@if command -v brew >/dev/null 2>&1; then \
if brew ls --versions golangci-lint >/dev/null 2>&1; then \
HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade golangci-lint; \
else \
HOMEBREW_NO_AUTO_UPDATE=1 brew install golangci-lint; \
fi; \
elif command -v golangci-lint >/dev/null 2>&1; then \
echo "Homebrew not found; using the golangci-lint already on PATH."; \
else \
echo "golangci-lint not found, and Homebrew is unavailable to install it."; \
echo "Install a build that matches this repo's Go version with:"; \
echo " GOTOOLCHAIN=go$(GO_VERSION) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest"; \
exit 1; \
fi

lint: deps vet ensure_golangci-lint ## Run linting
@golangci-lint run --timeout=5m --color always -v ./...
Expand Down
Loading