-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
110 lines (56 loc) · 1.09 KB
/
Makefile
File metadata and controls
110 lines (56 loc) · 1.09 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Variables
BINARY_NAME := app
BUILD_DIR := build
SRC := $(shell find . -name '*.go' -type f)
AIR := air # Ensure Air is installed and available in your PATH
# Commands
GO := go
GOFMT := gofmt
GOLINT := golangci-lint
# Default target
.PHONY: all
all: build
# Build the binary
.PHONY: build
build:
@mkdir -p $(BUILD_DIR)
$(GO) build -o $(BUILD_DIR)/$(BINARY_NAME) ./...
# Run the application
.PHONY: run
run:
$(GO) run main.go
# Watch for changes and reload using Air
.PHONY: watch
watch:
$(AIR)
# Clean build artifacts
.PHONY: clean
clean:
@rm -rf $(BUILD_DIR)
# Format the code
.PHONY: fmt
fmt:
$(GOFMT) -s -w .
# Run tests
.PHONY: test
test:
$(GO) test ./... -v
# Run linting
.PHONY: lint
lint:
$(GOLINT) run ./...
# Install dependencies
.PHONY: deps
deps:
$(GO) mod tidy
$(GO) mod download
# Debug build
.PHONY: debug
debug:
@mkdir -p $(BUILD_DIR)
$(GO) build -gcflags="all=-N -l" -o $(BUILD_DIR)/$(BINARY_NAME) ./...
# Release build
.PHONY: release
release:
@mkdir -p $(BUILD_DIR)
$(GO) build -ldflags="-s -w" -o $(BUILD_DIR)/$(BINARY_NAME) ./...