-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
74 lines (57 loc) · 1.79 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
74
.PHONY: build-server start-server stop-server live-reload test test-coverage clean-deps format clean-imports lint vet check-shadow lint-format migrate-create migrate-up
# Define variable for migration directory and PostgreSQL URL
MIGRATION_DIR = /migration
POSTGRESQL_URL = your_postgresql_connection_string # Replace with your actual connection string
# Docker tasks
build-server:
docker-compose -p go-vertical-slice-architecture build
start-server:
docker-compose up -d
stop-server:
docker-compose down
# Standalone usage for live reloading
live-reload:
air
# Testing
test:
go test ./...
test-coverage:
go test -cover ./...
# Cleaning, Formatting, Linting, and Vetting
clean-deps:
go mod tidy
format:
go fmt ./...
clean-imports:
goimports -l -w .
lint:
golangci-lint run ./...
vet:
go vet ./...
check-shadow:
shadow ./...
lint-format:
go fmt ./...
go vet ./...
golangci-lint run ./...
# Database Migration
migrate-create:
migrate create -ext sql -dir $(MIGRATIONS_DIR) -seq $(name)
migrate-up:
migrate -database $(POSTGRESQL_URL) -path $(MIGRATIONS_DIR) up
# Usage instructions:
# - To build the server: make build-server
# - To start the server: make start-server
# - To stop the server: make stop-server
# - For live reloading during development: make live-reload
# - To run tests: make test
# - To check test coverage: make test-coverage
# - To clean dependencies: make clean-deps
# - To format code: make format
# - To clean unused imports: make clean-imports
# - To lint code: make lint
# - To vet code: make vet
# - To check for shadowed variables: make check-shadow
# - To lint, format and vet your once: make lint-format
# - To create a migration script (replace your_script_name with the actual name): make migrate-create name=your_script_name
# - To run migration scripts: make migrate-up