-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (53 loc) · 1.32 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
# Variables
BINARY_NAME=app
SRC_DIR=cmd
MAIN=$(SRC_DIR)/main.go
BIN_DIR=bin
ENV_FILE=.env
# Default target to build the application
build:
@echo "Building the Go application..."
@mkdir -p $(BIN_DIR)
go build -o $(BIN_DIR)/$(BINARY_NAME) $(MAIN)
# Run the application
run: build
@echo "Running the Go application..."
./$(BIN_DIR)/$(BINARY_NAME)
# Tidy up the dependencies
tidy:
@echo "Tidying up Go modules..."
go mod tidy
# Install dependencies
deps:
@echo "Installing dependencies..."
go mod download
# Clean the directory
clean:
@echo "Cleaning up..."
@if exist $(BIN_DIR) (rmdir /S /Q $(BIN_DIR))
# Format the Go code
format:
@echo "Formatting Go code..."
go fmt ./...
# Check for issues with the code
lint:
@echo "Linting Go code..."
golangci-lint run
# Run tests
test:
@echo "Running tests..."
go test ./...
# Help menu
help:
@echo "Makefile commands:"
@echo " build - Build the Go application"
@echo " run - Run the Go application"
@echo " tidy - Tidy up Go modules"
@echo " deps - Install dependencies"
@echo " clean - Clean up generated files"
@echo " format - Format the Go code"
@echo " lint - Lint the Go code"
@echo " test - Run tests"
@echo " help - Display this help menu"
# Default target (help menu)
.DEFAULT_GOAL := help