62 lines
1.7 KiB
Makefile
62 lines
1.7 KiB
Makefile
.PHONY: help build run clean test install dev
|
|
|
|
help: ## Show this help message
|
|
@echo "XML Sitemap Generator API - Make Commands"
|
|
@echo ""
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
|
|
|
install: ## Install Go dependencies
|
|
@echo "📦 Installing dependencies..."
|
|
@go mod download
|
|
@echo "✅ Dependencies installed"
|
|
|
|
build: ## Build the application
|
|
@echo "🔨 Building..."
|
|
@go build -o sitemap-api .
|
|
@echo "✅ Build complete: ./sitemap-api"
|
|
|
|
run: build ## Build and run the application
|
|
@echo "🚀 Starting server on http://localhost:8080"
|
|
@./sitemap-api
|
|
|
|
dev: ## Run in development mode (with hot reload if air is installed)
|
|
@if command -v air > /dev/null; then \
|
|
air; \
|
|
else \
|
|
echo "💡 Tip: Install 'air' for hot reload: go install github.com/cosmtrek/air@latest"; \
|
|
$(MAKE) run; \
|
|
fi
|
|
|
|
clean: ## Clean build artifacts and database
|
|
@echo "🧹 Cleaning..."
|
|
@rm -f sitemap-api
|
|
@rm -f *.db
|
|
@rm -f *.db-journal
|
|
@echo "✅ Clean complete"
|
|
|
|
test: ## Run tests
|
|
@echo "🧪 Running tests..."
|
|
@go test -v ./...
|
|
|
|
format: ## Format code
|
|
@echo "📝 Formatting code..."
|
|
@go fmt ./...
|
|
@echo "✅ Code formatted"
|
|
|
|
lint: ## Run linter (requires golangci-lint)
|
|
@echo "🔍 Running linter..."
|
|
@if command -v golangci-lint > /dev/null; then \
|
|
golangci-lint run; \
|
|
else \
|
|
echo "❌ golangci-lint not installed. Install: https://golangci-lint.run/usage/install/"; \
|
|
fi
|
|
|
|
docker-build: ## Build Docker image
|
|
@echo "🐳 Building Docker image..."
|
|
@docker build -t sitemap-api .
|
|
@echo "✅ Docker image built: sitemap-api"
|
|
|
|
docker-run: docker-build ## Run in Docker container
|
|
@echo "🐳 Running in Docker..."
|
|
@docker run -p 8080:8080 sitemap-api
|