-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (63 loc) · 2.11 KB
/
Makefile
File metadata and controls
81 lines (63 loc) · 2.11 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
74
75
76
77
78
79
80
81
.PHONY: all build test lint fmt vet clean cover help
GO := go
GOFLAGS := -v
MODULE := github.com/danpasecinic/needle
COVERAGE_FILE := coverage.out
all: fmt lint test
build:
$(GO) build $(GOFLAGS) ./...
test:
$(GO) test $(GOFLAGS) -race ./...
test-short:
$(GO) test $(GOFLAGS) -short ./...
cover:
$(GO) test -race -coverprofile=$(COVERAGE_FILE) -covermode=atomic ./...
$(GO) tool cover -html=$(COVERAGE_FILE) -o coverage.html
@echo "Coverage report generated: coverage.html"
cover-func:
$(GO) test -race -coverprofile=$(COVERAGE_FILE) -covermode=atomic ./...
$(GO) tool cover -func=$(COVERAGE_FILE)
lint:
@which golangci-lint > /dev/null || (echo "Installing golangci-lint..." && go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
golangci-lint run ./...
lint-fix:
golangci-lint run --fix ./...
fmt:
$(GO) fmt ./...
@which goimports > /dev/null || go install golang.org/x/tools/cmd/goimports@latest
goimports -w .
vet:
$(GO) vet ./...
clean:
$(GO) clean
rm -f $(COVERAGE_FILE) coverage.html
tidy:
$(GO) mod tidy
deps:
$(GO) mod download
check: fmt vet lint test
bench:
$(GO) test -bench=. -benchmem ./...
doc:
@which godoc > /dev/null || go install golang.org/x/tools/cmd/godoc@latest
@echo "Starting godoc server at http://localhost:6060/pkg/$(MODULE)"
godoc -http=:6060
help:
@echo "Available targets:"
@echo " all - Format, lint, and test"
@echo " build - Build all packages"
@echo " test - Run tests with race detector"
@echo " test-short - Run short tests only"
@echo " cover - Generate coverage report"
@echo " cover-func - Show coverage by function"
@echo " lint - Run golangci-lint"
@echo " lint-fix - Run golangci-lint with auto-fix"
@echo " fmt - Format code with gofmt and goimports"
@echo " vet - Run go vet"
@echo " clean - Clean build artifacts"
@echo " tidy - Tidy go.mod"
@echo " deps - Download dependencies"
@echo " check - Run all checks (fmt, vet, lint, test)"
@echo " bench - Run benchmarks"
@echo " doc - Start godoc server"
@echo " help - Show this help"