55 lines
1.3 KiB
Makefile
55 lines
1.3 KiB
Makefile
.PHONY: help install-swag swagger build run dev clean deps
|
|
|
|
# Determine GOPATH
|
|
GOPATH ?= $(shell go env GOPATH)
|
|
SWAG := $(GOPATH)/bin/swag
|
|
|
|
# Default target
|
|
help:
|
|
@echo "Available targets:"
|
|
@echo " make install-swag - Install swag CLI if not present"
|
|
@echo " make swagger - Generate Swagger documentation"
|
|
@echo " make build - Build the application"
|
|
@echo " make run - Build and run the application"
|
|
@echo " make dev - Run in development mode"
|
|
@echo " make clean - Remove build artifacts"
|
|
@echo " make deps - Download dependencies"
|
|
|
|
# Check if swag is installed, install if not
|
|
install-swag:
|
|
@test -f $(SWAG) || \
|
|
(echo "Installing swag..." && \
|
|
go install github.com/swaggo/swag/cmd/swag@latest)
|
|
|
|
# Generate Swagger docs (auto-installs swag if needed)
|
|
swagger: install-swag
|
|
@echo "Generating Swagger documentation..."
|
|
@$(SWAG) init
|
|
|
|
# Build the application
|
|
build: swagger
|
|
@echo "Building application..."
|
|
@go build -o bin/api .
|
|
|
|
# Run the application
|
|
run: build
|
|
@echo "Starting server..."
|
|
@./bin/api
|
|
|
|
# Development mode with swagger generation
|
|
dev: swagger
|
|
@echo "Running in development mode..."
|
|
@go run .
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
@echo "Cleaning up..."
|
|
@rm -rf bin/
|
|
@rm -rf docs/
|
|
|
|
# Download dependencies
|
|
deps:
|
|
@echo "Downloading dependencies..."
|
|
@go mod download
|
|
@go mod tidy
|