-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (43 loc) · 1.8 KB
/
Makefile
File metadata and controls
49 lines (43 loc) · 1.8 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
# Makefile for filegoblin
# This provides convenient commands for building, testing, and linting the project.
# PHONY targets are not actual files - they're just command names.
# This prevents Make from getting confused if you have a file named "build" or "test".
.PHONY: build test lint clean help
# Default target - runs when you just type "make" with no arguments.
# Shows available commands and what they do.
help:
@echo "filegoblin - Makefile targets"
@echo ""
@echo " make build - Build the filegoblin binary"
@echo " make test - Run all tests"
@echo " make lint - Run linters (gofmt, go vet)"
@echo " make clean - Remove build artifacts"
@echo " make help - Show this help message"
# Build the project.
# Compiles the Go code and produces a binary named "filegoblin" in the current directory.
# -o flag specifies the output file name.
build:
@echo "Building filegoblin..."
go build -o filegoblin ./cmd/filegoblin
# Run all tests in the project.
# ./... means "this directory and all subdirectories recursively".
# -v flag makes test output verbose (shows which tests are running).
# -race flag enables the race detector to catch concurrent access bugs.
test:
@echo "Running tests..."
go test -v -race ./...
# Run linters to check code quality.
# gofmt checks if code is formatted correctly (run "gofmt -w ." to auto-fix).
# go vet checks for common mistakes like unreachable code or misused locks.
lint:
@echo "Checking code formatting..."
@test -z "$$(gofmt -l .)" || (echo "Code is not formatted. Run: gofmt -w ." && exit 1)
@echo "Running go vet..."
go vet ./...
@echo "Lint checks passed!"
# Remove build artifacts and temporary files.
# Deletes the compiled binary so you can rebuild from scratch.
clean:
@echo "Cleaning build artifacts..."
rm -f filegoblin
@echo "Clean complete!"