-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (35 loc) · 995 Bytes
/
Copy pathMakefile
File metadata and controls
45 lines (35 loc) · 995 Bytes
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
.PHONY: build test lint run clean
# Build variables
BINARY_NAME=url-shortener
COMMIT_HASH=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
TAG=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS=-ldflags "-X main.CommitHash=$(COMMIT_HASH) -X main.Tag=$(TAG)"
## build: Build the application binary
build:
go build $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/server
## run: Run the application
run: build
./bin/$(BINARY_NAME)
## test: Run all tests
test:
go test -race -count=1 ./...
## test-verbose: Run all tests with verbose output
test-verbose:
go test -race -count=1 -v ./...
## lint: Run linter (requires golangci-lint)
lint:
golangci-lint run ./...
## fmt: Format Go source files
fmt:
gofmt -s -w .
goimports -w .
## vet: Run go vet
vet:
go vet ./...
## clean: Remove build artifacts
clean:
rm -rf bin/
## help: Show this help message
help:
@echo "Usage:"
@sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's/^/ /'