frist
This commit is contained in:
58
Makefile
Normal file
58
Makefile
Normal file
@@ -0,0 +1,58 @@
|
||||
.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"
|
||||
Reference in New Issue
Block a user