generated from LontriTech/template-basic
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
49 lines (37 loc) · 904 Bytes
/
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
# https://www.gnu.org/software/make/
APP_NAME := app
CMD_DIR := ./cmd/$(APP_NAME)
OUTPUT_DIR := dist
OUTPUT_NAME := $(APP_NAME)
OUTPUT_PATH := $(OUTPUT_DIR)/$(OUTPUT_NAME)
GO_FILES := $(shell find . -type f -name '*.go')
.PHONY: all build run clean test fmt lint deps install
all: build
build: $(OUTPUT_PATH)
$(OUTPUT_PATH): $(GO_FILES)
@echo "Building the application..."
@mkdir -p $(OUTPUT_DIR)
@go build -o $(OUTPUT_PATH) $(CMD_DIR)
@echo "Build completed: $(OUTPUT_PATH)"
run: build
@echo "Running the application..."
@$(OUTPUT_PATH)
clean:
@echo "Cleaning up..."
@rm -rf $(OUTPUT_DIR)
@echo "Clean completed."
test:
@echo "Running tests..."
@go test ./...
fmt:
@echo "Formatting code..."
@go fmt ./...
lint:
@echo "Linting code..."
@golangci-lint run
deps:
@echo "Tidying dependencies..."
@go mod tidy
install:
@echo "Installing application..."
@go install $(CMD_DIR)