Files
ProxyPool/Makefile
2026-01-31 22:53:12 +08:00

59 lines
1.2 KiB
Makefile
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
.PHONY: build run test clean deps migrate
# 构建
build:
go build -o bin/proxyrotator ./cmd/server
# 运行
run:
go run ./cmd/server
# 测试
test:
go test -v ./...
# 清理
clean:
rm -rf bin/
# 安装依赖
deps:
go mod tidy
go mod download
# 数据库迁移(需要 psql
migrate:
@echo "Running database migration..."
@if [ -z "$(DATABASE_URL)" ]; then \
echo "DATABASE_URL is not set"; \
exit 1; \
fi
psql "$(DATABASE_URL)" -f migrations/001_init.sql
# 开发模式(自动重载)
dev:
@which air > /dev/null || go install github.com/cosmtrek/air@latest
air
# 格式化代码
fmt:
go fmt ./...
# 静态检查
lint:
@which golangci-lint > /dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run
# 帮助
help:
@echo "Available targets:"
@echo " build - Build the binary"
@echo " run - Run the server"
@echo " test - Run tests"
@echo " clean - Remove build artifacts"
@echo " deps - Install dependencies"
@echo " migrate - Run database migrations"
@echo " dev - Run with hot reload (requires air)"
@echo " fmt - Format code"
@echo " lint - Run linter"