-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmakefile
82 lines (62 loc) · 1.73 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
80
81
82
# Makefile for axios4go
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=gofmt
GOVET=$(GOCMD) vet
GOCOVER=$(GOCMD) tool cover
# Binary name
BINARY_NAME=axios4go
# Test flags
TEST_FLAGS=-v
RACE_FLAGS=-race
COVERAGE_FLAGS=-coverprofile=coverage.out
all: test build
build:
$(GOBUILD) -o $(BINARY_NAME) -v
test:
$(GOTEST) $(TEST_FLAGS) $(shell go list ./... | grep -v /examples)
test-race:
$(GOTEST) $(TEST_FLAGS) $(RACE_FLAGS) $(shell go list ./... | grep -v /examples)
test-coverage:
$(GOTEST) $(TEST_FLAGS) $(COVERAGE_FLAGS) $(shell go list ./... | grep -v /examples)
$(GOCOVER) -func=coverage.out
test-all: test test-race test-coverage
benchmark:
$(GOTEST) -run=^$$ -bench=. -benchmem $(shell go list ./... | grep -v /examples)
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME) coverage.out
run:
$(GOBUILD) -o $(BINARY_NAME) -v
./$(BINARY_NAME)
deps:
$(GOGET) -v -t -d ./...
$(GOMOD) tidy
# Format all Go files
fmt:
$(GOFMT) -s -w .
# Run go vet
vet:
$(GOVET) ./...
# Run gocyclo
cyclo:
@which gocyclo > /dev/null || go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
gocyclo -over 15 .
# Check examples
check-examples:
@echo "Checking Go files in examples/ ..."
@find examples -type f -name '*.go' | while read file; do \
echo " Checking $$file"; \
$(GOCMD) build -o /dev/null "$$file" || exit 1; \
done
# Run all checks and tests
check: fmt vet cyclo test-all check-examples
# Install gocyclo if not present
install-gocyclo:
@which gocyclo > /dev/null || go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
.PHONY: all build test test-race test-coverage test-all benchmark clean run deps fmt vet cyclo check-examples check install-gocyclo