-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
79 lines (62 loc) · 1.55 KB
/
Makefile
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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
GOMOD=$(GOCMD) mod
BINARY_NAME=readgo
# Linting
GOLINT=golangci-lint
# Build flags
BUILD_FLAGS=-v
# Test flags
TEST_FLAGS=-v -race -count=1
.PHONY: all build test clean vet lint fmt mod-tidy check pre-commit help
all: build
build:
$(GOBUILD) $(BUILD_FLAGS) ./...
# Run tests
test:
$(GOTEST) $(TEST_FLAGS) ./...
# Run go vet
vet:
$(GOVET) ./...
# Run golangci-lint
lint:
$(GOLINT) run
# Format code
fmt:
$(GOCMD) fmt ./...
# Tidy modules
mod-tidy:
$(GOMOD) tidy
# Clean build files
clean:
$(GOCMD) clean
rm -f $(BINARY_NAME)
# Run all checks (pre-commit)
check: fmt mod-tidy vet lint test
@echo "All checks passed!"
# Pre-commit hook
pre-commit: check
@echo "Ready to commit!"
# Install development tools
install-tools:
@echo "Installing development tools..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Show help
help:
@echo "Available commands:"
@echo " make build - Build the project"
@echo " make test - Run tests"
@echo " make vet - Run go vet"
@echo " make lint - Run golangci-lint"
@echo " make fmt - Format code"
@echo " make mod-tidy - Tidy go modules"
@echo " make clean - Clean build files"
@echo " make check - Run all checks (fmt, mod-tidy, vet, lint, test)"
@echo " make pre-commit - Run all checks before commit"
@echo " make install-tools - Install development tools"
@echo " make help - Show this help message"
# Default target
.DEFAULT_GOAL := help