-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (42 loc) · 1.37 KB
/
Makefile
File metadata and controls
52 lines (42 loc) · 1.37 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
.PHONY: all clean tests lint build format coverage benchmarks
all: build tests lint
# Run tests with coverage
tests:
@echo "Running tests with coverage..."
go test -v -race -covermode=atomic -coverprofile=coverage.out ./...
@go tool cover -func=coverage.out
@if command -v go >/dev/null 2>&1; then \
go tool cover -html=coverage.out -o coverage.html; \
fi
# Run benchmarks
benchmarks:
@echo "Running benchmarks..."
go test -run=^$$ -bench=. -benchmem ./...
# Build the package
build:
@echo "Building package..."
go build ./...
# Format code
format:
@echo "Formatting code..."
@find . -type f -name "*.go" -not -path "./vendor/*" -print0 | xargs -0 gofmt -s -w
@find . -type f -name "*.go" -not -path "./vendor/*" -print0 | xargs -0 goimports -w
@find . -type f -name "*.go" -not -path "./vendor/*" -print0 | xargs -0 golines -m 120 -w
# Lint code
lint:
@echo "Linting code..."
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not installed, skipping lint"; \
fi
# Generate coverage report
coverage: tests
@go tool cover -html=coverage.out
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@find . -type f -name "*.test" -delete
@find . -type f -name "coverage.out" -delete
@find . -type f -name "coverage.html" -delete
@find . -type d -name "vendor" -exec rm -rf {} + 2>/dev/null || true