Files
DarkiT 9a640012a6 init
2025-03-16 20:02:41 +08:00

72 lines
1.4 KiB
Bash

#!/bin/bash
# 规则引擎开发环境脚本
set -e
# 检查是否安装了air
check_air() {
if ! command -v air &> /dev/null; then
echo "未检测到Air. 正在安装..."
go install github.com/cosmtrek/air@latest
echo "Air安装完成!"
else
echo "检测到Air已安装."
fi
}
# 检查tmp目录
check_tmp_dir() {
if [ ! -d "tmp" ]; then
echo "创建tmp目录..."
mkdir -p tmp
fi
}
# 启动开发环境
start_dev() {
echo "启动规则引擎开发环境..."
# 设置Go代理
export GOPROXY=https://goproxy.cn,direct
echo "已设置GOPROXY=${GOPROXY}"
# 运行air
if [ -f ".air.toml" ]; then
echo "使用.air.toml配置启动..."
air
else
echo "Error: .air.toml配置文件不存在。"
exit 1
fi
}
# 清理临时文件
clean_tmp() {
echo "清理临时文件..."
if [ -d "tmp" ]; then
rm -rf tmp
echo "tmp目录已清理"
fi
}
# 主要逻辑
case "$1" in
start)
check_air
check_tmp_dir
start_dev
;;
clean)
clean_tmp
;;
*)
echo "规则引擎开发环境工具"
echo ""
echo "用法: $0 [命令]"
echo ""
echo "命令:"
echo " start 启动开发环境(使用Air热重载)"
echo " clean 清理临时文件"
echo ""
;;
esac