Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
with:
go-version-file: "go.mod"

- name: Vet
run: go vet ./...
- name: Lint (gofmt check + go vet)
run: make lint

- name: Build
run: go build -v ./...
Expand Down
34 changes: 25 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ menu:
@printf " $(BOLD)$(GREEN)=== Testing ===$(RESET)\n"
@printf " $(YELLOW)4)$(RESET) make test $(DIM)Run all tests$(RESET)\n"
@printf " $(YELLOW)5)$(RESET) make test-verbose $(DIM)Run tests with verbose output$(RESET)\n"
@printf " $(YELLOW)6)$(RESET) make lint $(DIM)Run go vet$(RESET)\n"
@printf "\n"
@printf " $(BOLD)$(GREEN)=== Code Quality ===$(RESET)\n"
@printf " $(YELLOW)6)$(RESET) make fmt $(DIM)Format code with gofmt$(RESET)\n"
@printf " $(YELLOW)7)$(RESET) make lint $(DIM)Check formatting + go vet$(RESET)\n"
@printf "\n"
@printf " $(BOLD)$(GREEN)=== Maintenance ===$(RESET)\n"
@printf " $(YELLOW)7)$(RESET) make clean $(DIM)Remove build artifacts$(RESET)\n"
@printf " $(YELLOW)8)$(RESET) make tidy $(DIM)Tidy Go modules$(RESET)\n"
@printf " $(YELLOW)8)$(RESET) make clean $(DIM)Remove build artifacts$(RESET)\n"
@printf " $(YELLOW)9)$(RESET) make tidy $(DIM)Tidy Go modules$(RESET)\n"
@printf "\n"
@read -p " Enter choice: " choice; \
case $$choice in \
Expand All @@ -38,9 +41,10 @@ menu:
3) $(MAKE) run ;; \
4) $(MAKE) test ;; \
5) $(MAKE) test-verbose ;; \
6) $(MAKE) lint ;; \
7) $(MAKE) clean ;; \
8) $(MAKE) tidy ;; \
6) $(MAKE) fmt ;; \
7) $(MAKE) lint ;; \
8) $(MAKE) clean ;; \
9) $(MAKE) tidy ;; \
*) echo "Invalid choice" ;; \
esac

Expand All @@ -59,7 +63,17 @@ test:
test-verbose:
$(GO) test -v ./...

lint:
fmt:
gofmt -w .

fmt-check:
@if [ -n "$$(gofmt -l .)" ]; then \
echo "These files need formatting (run 'make fmt'):"; \
gofmt -l .; \
exit 1; \
fi

lint: fmt-check
$(GO) vet ./...

clean:
Expand All @@ -78,11 +92,13 @@ help:
@printf " $(CYAN)make run$(RESET) Run with go run\n"
@printf " $(CYAN)make test$(RESET) Run all tests\n"
@printf " $(CYAN)make test-verbose$(RESET) Run tests with verbose output\n"
@printf " $(CYAN)make lint$(RESET) Run go vet\n"
@printf " $(CYAN)make fmt$(RESET) Format code with gofmt\n"
@printf " $(CYAN)make fmt-check$(RESET) Check formatting (fails if unformatted)\n"
@printf " $(CYAN)make lint$(RESET) Check formatting + go vet\n"
@printf " $(CYAN)make clean$(RESET) Remove build artifacts\n"
@printf " $(CYAN)make tidy$(RESET) Tidy Go modules\n"
@printf "\n"

list: help

.PHONY: menu build install run test test-verbose lint clean tidy help list
.PHONY: menu build install run test test-verbose fmt fmt-check lint clean tidy help list
Loading