build: update Makefile + add linter configuration

This commit is contained in:
2025-12-04 17:33:56 +02:00
parent 0022b8c06a
commit 3c0f038001
2 changed files with 30 additions and 5 deletions

12
.golangci.yml Normal file
View File

@@ -0,0 +1,12 @@
version: "2"
linters:
enable:
- staticcheck
- govet
- errcheck
- ineffassign
- unused
- gocritic
- intrange
- modernize

View File

@@ -1,12 +1,19 @@
all: run BIN := $(notdir $(CURDIR))
all:
@if [ ! -f ".git/hooks/pre-commit" ]; then \
$(MAKE) precommit-install; \
fi
$(MAKE) build
$(MAKE) run
.PHONY: build .PHONY: build
build: build:
go build go build -o $(BIN)
.PHONY: run .PHONY: run
run: build run: build
./vstask ./$(BIN)
.PHONY: test .PHONY: test
test: test:
@@ -14,11 +21,15 @@ test:
.PHONY: install .PHONY: install
install: build install: build
cp vstask ~/.local/bin cp $(BIN) ~/.local/bin/
.PHONY: uninstall .PHONY: uninstall
uninstall: uninstall:
rm -f ~/.local/bin/vstask rm -f ~/.local/bin/$(BIN)
.PHONY: lint
lint:
golangci-lint run ./...
.PHONY: precommit-install .PHONY: precommit-install
precommit-install: precommit-install:
@@ -33,9 +44,11 @@ precommit:
if [ -z "$$STAGED_FILES" ]; then \ if [ -z "$$STAGED_FILES" ]; then \
echo "No staged Go files to check."; \ echo "No staged Go files to check."; \
else \ else \
set -e; \
echo "Running pre-commit checks..."; \ echo "Running pre-commit checks..."; \
echo "go fmt"; \ echo "go fmt"; \
go fmt ./...; \ go fmt ./...; \
git add $$STAGED_FILES; \
echo "go vet"; \ echo "go vet"; \
go vet ./...; \ go vet ./...; \
echo "golangci-lint"; \ echo "golangci-lint"; \