-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (58 loc) · 2.12 KB
/
Copy pathMakefile
File metadata and controls
73 lines (58 loc) · 2.12 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
GOCMD ?= go
.DEFAULT_GOAL := help
##@ General
help: ## Show this help message with available targets
@awk 'BEGIN {FS=":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\n"} \
/^[a-zA-Z0-9_.-]+:.*##/ { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 } \
/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0,5) }' $(MAKEFILE_LIST)
.PHONY: help
##@ Linting & Formatting
linters-install: ## Install golangci-lint locally if missing (latest)
@command -v golangci-lint >/dev/null 2>&1 || { \
echo "Installing golangci-lint (latest)..."; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
| sh -s -- -b $$(go env GOPATH)/bin; \
}
.PHONY: linters-install
lint: ## Run all linters and auto-fix issues (golangci-lint run --fix)
golangci-lint run --fix
.PHONY: lint
lint-staged: ## Lint only staged changes (pre-commit style)
@tmp=$$(mktemp); \
git diff --cached > $$tmp; \
golangci-lint run --new-from-patch="$$tmp"; \
rm -f "$$tmp"
.PHONY: lint-staged
format: ## Format code with gofumpt (in-place)
gofumpt -w .
.PHONY: format
##@ Test & Bench
test: ## Run unit tests with race detector and coverage
$(GOCMD) test -race -cover ./...
.PHONY: test
bench: ## Run benchmarks with memory stats
$(GOCMD) test -run=NONE -bench=. -benchmem ./...
.PHONY: bench
playground: ## Execute quick playground program (tests/playground.go)
$(GOCMD) run ./tests/playground.go
.PHONY: playground
##@ Dev Apps
api: ## Run API dev test app (cmd/dev-api-test)
$(GOCMD) run ./cmd/dev-api-test
.PHONY: api
loginQR: ## Run login-QR dev app (cmd/dev-login-qr)
$(GOCMD) run ./cmd/dev-login-qr
.PHONY: loginQR
listener: ## Run listener dev app (cmd/dev-listener)
$(GOCMD) run ./cmd/dev-listener
.PHONY: listener
gen-endpoint: ## Generate endpoint skeleton (usage: make gen-endpoint NAME=SendMessage)
$(GOCMD) run ./cmd/gen-endpoint -name=$(NAME)
.PHONY: gen-endpoint
##@ Examples
ex-login: ## Run login example (examples/login/login.go)
$(GOCMD) run ./examples/login/login.go
.PHONY: ex-login
ex-echobot: ## Run echo-bot example (examples/echobot/echobot.go)
$(GOCMD) run ./examples/echobot/echobot.go
.PHONY: ex-echobot