-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (48 loc) · 1.32 KB
/
Copy pathMakefile
File metadata and controls
57 lines (48 loc) · 1.32 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
# Makefile for Go projects with pre-commit integration
# Default Go commands
GO := go
GOFLAGS := -v
# Default target: run pre-commit
.PHONY: all
all: pre-commit
# Install dependencies
.PHONY: deps
deps:
$(GO) get -u ./...
$(GO) mod tidy
$(GO) mod download
# Format code
.PHONY: fmt
fmt:
$(GO) fmt ./...
gofmt -s -w .
# Lint code (requires golangci-lint to be installed)
.PHONY: lint
lint:
golangci-lint run --fix
# Test the project
.PHONY: test
test:
$(GO) test $(GOFLAGS) ./...
# Generate documentation with godoc
.PHONY: docs
docs:
@echo "Starting godoc server at http://localhost:6060"
@echo "Visit http://localhost:6060/pkg/golog.qntx.fun/ to view your package documentation"
godoc -http=:6060
# Pre-commit: run all checks before commit
.PHONY: pre-commit
pre-commit: deps fmt lint test
pre-commit run --all-files
# Help message
.PHONY: help
help:
@echo "Available targets:"
@echo " make - Run pre-commit (default)"
@echo " make deps - Install and tidy dependencies"
@echo " make fmt - Format Go code"
@echo " make lint - Run linter (requires golangci-lint)"
@echo " make test - Run all tests"
@echo " make docs - Start godoc server for documentation"
@echo " make pre-commit - Run all pre-commit checks (deps, fmt, lint, test)"
@echo " make help - Show this help message"