Add a Makefile, so one command is the whole check

Verifying a change meant four invocations — gofmt, go vet, go build, go
test — and remembering the order. `make` is all of them with one exit code.

gofmt needs the wrapper: it reports offending files on stdout and still
exits 0, so a bare `gofmt -l .` in a target would never fail the build.
This commit is contained in:
Esa Kataja
2026-09-05 13:46:30 +03:00
parent 2af29fe999
commit 5db19b26ae
2 changed files with 29 additions and 3 deletions
+24
View File
@@ -0,0 +1,24 @@
# One command before committing: make
#
# gofmt is first because a formatting failure is the cheapest to fix, and it is the only check that
# needs a wrapper — gofmt reports offending files on stdout and still exits 0.
.POSIX:
.PHONY: check fmt vet test build run
check: fmt vet test
fmt:
@out=$$(gofmt -l .); test -z "$$out" || { echo "not gofmt'd:"; echo "$$out"; exit 1; }
vet:
go vet ./...
test:
go test ./...
build:
go build -o levyraati26-go .
# Templates and migrations are embedded, so seeing a change means rebuilding.
run: build
./levyraati26-go