This repository was archived by the owner on Dec 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
93 lines (77 loc) · 2.05 KB
/
Makefile
File metadata and controls
93 lines (77 loc) · 2.05 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
.PHONY: build run test clean install deps
# Application name
APP_NAME := wgeasygo
# Build directory
BUILD_DIR := build
# Go parameters
GOCMD := go
GOBUILD := $(GOCMD) build
GOTEST := $(GOCMD) test
GOGET := $(GOCMD) get
GOMOD := $(GOCMD) mod
# Build the application
build:
@echo "Building $(APP_NAME)..."
CGO_ENABLED=1 $(GOBUILD) -ldflags="-s -w" -o $(APP_NAME) ./cmd/api
# Build for production (static binary)
build-prod:
@echo "Building $(APP_NAME) for production..."
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags="-s -w" -o $(APP_NAME) ./cmd/api
# Run the application
run: build
@echo "Running $(APP_NAME)..."
./$(APP_NAME)
# Run with development config
dev:
@echo "Running in development mode..."
GIN_MODE=debug ./$(APP_NAME)
# Download dependencies
deps:
@echo "Downloading dependencies..."
$(GOMOD) download
$(GOMOD) tidy
# Run tests
test:
@echo "Running tests..."
$(GOTEST) -v ./...
# Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
# Clean build artifacts
clean:
@echo "Cleaning..."
rm -f $(APP_NAME)
rm -f coverage.out coverage.html
rm -rf $(BUILD_DIR)
# Install to system
install: build-prod
@echo "Installing..."
sudo bash scripts/install.sh
# Format code
fmt:
@echo "Formatting code..."
$(GOCMD) fmt ./...
# Lint code
lint:
@echo "Linting code..."
golangci-lint run
# Generate API documentation
docs:
@echo "Generating API documentation..."
swag init -g cmd/api/main.go
# Help
help:
@echo "Available targets:"
@echo " build - Build the application"
@echo " build-prod - Build for production"
@echo " run - Build and run"
@echo " dev - Run in development mode"
@echo " deps - Download dependencies"
@echo " test - Run tests"
@echo " test-coverage - Run tests with coverage"
@echo " clean - Clean build artifacts"
@echo " install - Install to system"
@echo " fmt - Format code"
@echo " lint - Lint code"