golang-template/Makefile
2026-08-18 08:04:20 +03:00

41 lines
1.1 KiB
Makefile

.PHONY: help setup run dev build fmt migrate-up migrate-down migrate-status migrate-create generate docker-build
.DEFAULT_GOAL := help
help: ## List available targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}'
setup: ## Copy .env, tidy modules, enable git hooks
cp -n .env.example .env || true
go mod tidy
git config core.hooksPath .githooks
run: ## Run the server
go run ./cmd
dev: ## Run the server with live reload (air)
air
build: ## Build the server binary to ./tmp/main
go build -o ./tmp/main ./cmd
fmt: ## Format all Go files
gofmt -l -w .
migrate-up: ## Apply all pending migrations
./scripts/goose.sh up
migrate-down: ## Roll back the last migration
./scripts/goose.sh down
migrate-status: ## Show migration status
./scripts/goose.sh status
migrate-create: ## Create a new migration (name=add_widgets)
./scripts/goose-create.sh $(name)
generate: ## Run sqlc codegen
sqlc generate
docker-build: ## Build the Docker image
docker build -t go-backend .