/
Makefile
74 lines (56 loc) 路 1.36 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
# Makefile for Go project
# Go parameters
GOCMD = go
BINARY_NAME_WIN = chabo-api.exe
BINARY_NAME_UNIX = chabo-api.o
.PHONY: deps-upgrade deps
# Main build target
all: deps test build
# Build the application
build:
$(GOCMD) build -o $(BINARY_NAME_WIN) -v
# Build for Linux
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOCMD) build -o $(BINARY_NAME_UNIX) -v
# Clean the build artifacts
clean:
$(GOCMD) clean
rm -f $(BINARY_NAME_WIN)
rm -f $(BINARY_NAME_UNIX)
# Run tests
test:
$(GOCMD) test -v ./...
# Install project dependencies
deps:
$(GOCMD) mod download
$(GOCMD) mod tidy
$(GOCMD) mod vendor
# Upgrade project dependencies
deps-upgrade:
$(GOCMD) get -u -t ./...
$(GOCMD) mod download
$(GOCMD) mod tidy
$(GOCMD) mod vendor
# Generate Swagger config
swag:
swag init -d ./internal/api,./ -g router.go
# Run the application
run: swag
$(GOCMD) run .
# Format the code
fmt:
$(GOCMD) fmt ./...
golines . -w --ignored-dirs=vendor
# Lint the code using a linter tool
lint:
golangci-lint run
# Generate code coverage report
coverage:
$(GOCMD) test -coverprofile='coverage.out' ./...
$(GOCMD) tool cover -html=coverage.out
# Generate documentation using tools like godoc
doc:
godoc -http=:6060
# Perform a full code quality check (lint, tests, coverage)
check: lint test coverage
.PHONY: all build build-linux clean test deps run fmt lint coverage doc check