.PHONY: test fmt fmt-check lint check docker hooks

default: check

test:
	@go test -v ./...

fmt:
	goimports -l -w .
	golangci-lint run --fix

fmt-check:
	@test -z "$$(gofmt -l .)" || { echo "gofmt would reformat:"; gofmt -l .; exit 1; }

lint:
	golangci-lint run

check: fmt-check lint test

docker:
	docker build --progress plain .

hooks:
	@echo "Installing git hooks..."
	@mkdir -p .git/hooks
	@printf '#!/bin/sh\nmake check\n' > .git/hooks/pre-commit
	@chmod +x .git/hooks/pre-commit
	@echo "Pre-commit hook installed."
