File tree Expand file tree Collapse file tree 2 files changed +80
-6
lines changed Expand file tree Collapse file tree 2 files changed +80
-6
lines changed Original file line number Diff line number Diff line change @@ -28,4 +28,4 @@ func main() {
28
28
// This will always be executed
29
29
fmt .Println ("Request completed" )
30
30
})
31
- }
31
+ }
Original file line number Diff line number Diff line change 1
- .PHONY : lint format
1
+ # Makefile for axios4go project
2
2
3
- lint :
4
- golangci-lint run --verbose * .go
3
+ # Go parameters
4
+ GOCMD =go
5
+ GOBUILD =$(GOCMD ) build
6
+ GOCLEAN =$(GOCMD ) clean
7
+ GOTEST =$(GOCMD ) test
8
+ GOGET =$(GOCMD ) get
9
+ GOMOD =$(GOCMD ) mod
10
+ GOFMT =gofmt
11
+ GOVET =$(GOCMD ) vet
12
+ GOCOVER =$(GOCMD ) tool cover
5
13
6
- format :
7
- goimports -w * .go
14
+ # Binary name
15
+ BINARY_NAME =axios4go
16
+
17
+ # Test flags
18
+ TEST_FLAGS =-v
19
+ RACE_FLAGS =-race
20
+ COVERAGE_FLAGS=-coverprofile =coverage.out
21
+
22
+ all : test build
23
+
24
+ build :
25
+ $(GOBUILD ) -o $(BINARY_NAME ) -v
26
+
27
+ test :
28
+ $(GOTEST ) $(TEST_FLAGS ) $(shell go list ./... | grep -v /examples)
29
+
30
+ test-race :
31
+ $(GOTEST ) $(TEST_FLAGS ) $(RACE_FLAGS ) $(shell go list ./... | grep -v /examples)
32
+
33
+ test-coverage :
34
+ $(GOTEST ) $(TEST_FLAGS ) $(COVERAGE_FLAGS ) $(shell go list ./... | grep -v /examples)
35
+ $(GOCOVER ) -func=coverage.out
36
+
37
+ test-all : test test-race test-coverage
38
+
39
+ benchmark :
40
+ $(GOTEST ) -run=^$$ -bench=. -benchmem $(shell go list ./... | grep -v /examples)
41
+
42
+ clean :
43
+ $(GOCLEAN )
44
+ rm -f $(BINARY_NAME ) coverage.out
45
+
46
+ run :
47
+ $(GOBUILD ) -o $(BINARY_NAME ) -v
48
+ ./$(BINARY_NAME )
49
+
50
+ deps :
51
+ $(GOGET ) -v -t -d ./...
52
+ $(GOMOD ) tidy
53
+
54
+ # Format all Go files
55
+ fmt :
56
+ $(GOFMT ) -s -w .
57
+
58
+ # Run go vet
59
+ vet :
60
+ $(GOVET ) ./...
61
+
62
+ # Run gocyclo
63
+ cyclo :
64
+ @which gocyclo > /dev/null || go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
65
+ gocyclo -over 15 .
66
+
67
+ # Check examples
68
+ check-examples :
69
+ @for file in examples/* .go; do \
70
+ echo " Checking $$ file" ; \
71
+ $(GOCMD ) build -o /dev/null $$ file || exit 1; \
72
+ done
73
+
74
+ # Run all checks and tests
75
+ check : fmt vet cyclo test-all check-examples
76
+
77
+ # Install gocyclo if not present
78
+ install-gocyclo :
79
+ @which gocyclo > /dev/null || go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
80
+
81
+ .PHONY : all build test test-race test-coverage test-all benchmark clean run deps fmt vet cyclo check-examples check install-gocyclo
You can’t perform that action at this time.
0 commit comments