Add fmt command to makefile

This commit is contained in:
Riyyi
2026-05-03 10:22:30 +02:00
parent d36bba6925
commit 39b8d9ac4b
+5 -2
View File
@@ -1,4 +1,4 @@
.PHONY: build fmt vet check githook install uninstall .PHONY: build fmt fmtcheck vet check githook install uninstall
PKG := github.com/Riyyi/declpac PKG := github.com/Riyyi/declpac
BIN := declpac BIN := declpac
@@ -15,6 +15,9 @@ build:
go build -o $(BUILD) ./cmd/declpac go build -o $(BUILD) ./cmd/declpac
fmt: fmt:
@gofmt -w cmd pkg
fmtcheck:
@if [ -z "$(STAGED_GO)" ]; then exit 0; fi; \ @if [ -z "$(STAGED_GO)" ]; then exit 0; fi; \
unformatted=$$(gofmt -l $(STAGED_GO)); \ unformatted=$$(gofmt -l $(STAGED_GO)); \
if [ -n "$$unformatted" ]; then \ if [ -n "$$unformatted" ]; then \
@@ -26,7 +29,7 @@ vet:
@if [ -z "$(STAGED_GO)" ]; then exit 0; fi; \ @if [ -z "$(STAGED_GO)" ]; then exit 0; fi; \
go vet $(STAGED_PKGS) go vet $(STAGED_PKGS)
check: fmt vet check: fmtcheck vet
githook: githook:
@mkdir -p .git/hooks @mkdir -p .git/hooks