-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
73 lines (61 loc) · 1.77 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
BINARY_NAME=gotiny
PACKAGE=github.com/RajNykDhulapkar/gotiny
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=1
# Default target
all: run
# Run the application
run:
@echo "Starting the GoTiny application..."
@go run main.go
# Build the application
build:
@echo "Building the GoTiny application..."
@go build -o ./bin/$(BINARY_NAME) main.go
@echo "Build complete! Binary generated: ./bin/$(BINARY_NAME)"
# Test the application
test:
@echo "Running tests..."
@go test ./... -v
# Clean up generated files and binaries
clean:
@echo "Cleaning up binaries and temporary files..."
@go clean
@rm -f $(BINARY_NAME)
# Docker compose to start Redis (Assumes you have a docker-compose.yml)
start-redis:
@echo "Starting Redis container with Docker..."
@docker run --name gotiny-redis -p $(REDIS_PORT):$(REDIS_PORT) -d redis
stop-redis:
@echo "Stopping Redis container..."
@docker stop gotiny-redis
@docker rm gotiny-redis
# Lint the codebase
lint:
@echo "Linting the codebase..."
@golangci-lint run ./...
# Format the Go code
format:
@echo "Formatting Go code..."
@go fmt ./...
# Install dependencies
deps:
@echo "Downloading dependencies..."
@go mod tidy
# Rebuild everything
rebuild: clean build
# Help
help:
@echo "Makefile commands:"
@echo " run - Run the application"
@echo " build - Build the application"
@echo " test - Run tests"
@echo " clean - Clean up binaries and temporary files"
@echo " start-redis - Start a Redis instance using Docker"
@echo " stop-redis - Stop the Redis Docker container"
@echo " lint - Lint the codebase"
@echo " format - Format the Go code"
@echo " deps - Install dependencies"
@echo " rebuild - Clean and rebuild the project"
@echo " help - Show this help message"