summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMurilo Ijanc <[email protected]>2026-07-26 12:13:27 -0300
committerMurilo Ijanc <[email protected]>2026-07-26 12:13:27 -0300
commit625cab052606cb3c2a7c4e008c43cf536b6404ce (patch)
tree80d126ce42750d29eec42d9fef98a68341bb2dfa /Makefile
downloadgo-625cab052606cb3c2a7c4e008c43cf536b6404ce.tar.gz
Initial import
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile50
1 files changed, 50 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ab805de
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,50 @@
+# Development tasks. Everything runs through the `go` tool, so there is
+# nothing to install first.
+#
+# make list the targets
+# make test run the suite
+# make lint gofmt check + go vet, no files touched
+# make build compile every package
+GO ?= go
+
+.DEFAULT_GOAL := help
+.PHONY: help test test-race lint format build check clean
+
+help:
+ @echo 'Targets:'
+ @echo ' test run the test suite'
+ @echo ' test-race run it under the race detector'
+ @echo ' lint gofmt -l + go vet (read-only)'
+ @echo ' format apply gofmt (writes)'
+ @echo ' build compile every package'
+ @echo ' check lint + test + build, in that order'
+ @echo ' clean remove build and test artefacts'
+
+test:
+ $(GO) test ./...
+
+test-race:
+ $(GO) test -race -count=1 ./...
+
+# Read-only by design, so it is safe in CI and in a pre-commit hook: it reports
+# what `make format` would change without changing anything.
+lint:
+ @files=$$(gofmt -l .); \
+ if [ -n "$$files" ]; then \
+ echo 'gofmt would rewrite:'; echo "$$files"; exit 1; \
+ fi
+ $(GO) vet ./...
+
+format:
+ gofmt -w .
+
+build:
+ $(GO) build ./...
+
+# The order matters: lint is the fastest to fail, so a broken run reports the
+# cheapest problem first.
+check: lint test build
+
+clean:
+ $(GO) clean -testcache
+ rm -f coverage.out coverage.html