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
build:
go build
go build -o $(BIN)
.PHONY: run
run: build
./vstask
./$(BIN)
.PHONY: test
test:
@@ -14,11 +21,15 @@ test:
.PHONY: install
install: build
cp vstask ~/.local/bin
cp $(BIN) ~/.local/bin/
.PHONY: uninstall
uninstall:
rm -f ~/.local/bin/vstask
rm -f ~/.local/bin/$(BIN)
.PHONY: lint
lint:
golangci-lint run ./...
.PHONY: precommit-install
precommit-install:
@@ -33,9 +44,11 @@ precommit:
if [ -z "$$STAGED_FILES" ]; then \
echo "No staged Go files to check."; \
else \
set -e; \
echo "Running pre-commit checks..."; \
echo "go fmt"; \
go fmt ./...; \
git add $$STAGED_FILES; \
echo "go vet"; \
go vet ./...; \
echo "golangci-lint"; \