Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (40 loc) · 1.45 KB
/
Copy pathMakefile
File metadata and controls
53 lines (40 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Makefile for warmbly-go — the official Go SDK for Warmbly.
#
# Common entry points:
# make # show this help
# make check # fmt + vet + lint + test (run before committing)
#
# Requires: Go 1.23+. The `lint` target additionally requires golangci-lint,
# and `fmt` will use goimports when it is available on PATH.
GO ?= go
GOLANGCI ?= golangci-lint
.DEFAULT_GOAL := help
.PHONY: help build test cover lint fmt vet tidy check clean
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}'
build: ## Compile all packages
$(GO) build ./...
test: ## Run tests with the race detector
$(GO) test -race ./...
cover: ## Run tests with coverage and print a per-function report
$(GO) test -race -coverprofile=coverage.out ./...
$(GO) tool cover -func=coverage.out
lint: ## Run golangci-lint
$(GOLANGCI) run
fmt: ## Format code (gofmt -s, plus goimports if available)
gofmt -s -w .
@if command -v goimports >/dev/null 2>&1; then \
goimports -w -local github.com/warmbly/warmbly-go .; \
else \
echo "goimports not found; skipping (run: go install golang.org/x/tools/cmd/goimports@latest)"; \
fi
vet: ## Run go vet
$(GO) vet ./...
tidy: ## Tidy and verify the module graph
$(GO) mod tidy
check: fmt vet lint test ## Run fmt, vet, lint and test
clean: ## Remove build and coverage artifacts
$(GO) clean ./...
rm -f coverage.out