setup-gentool.sh 686 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # 安装 gentool 的脚本
  3. # 用于安装 gorm.io/gen/tools/gentool 工具
  4. # https://gorm.io/zh_CN/gen/gen_tool.html
  5. # 检查 gentool 是否已安装
  6. if command -v gentool >/dev/null 2>&1; then
  7. echo "✅ gentool 已安装"
  8. else
  9. echo "📥 开始安装 gentool..."
  10. # 设置 GOPROXY 环境变量
  11. export GOPROXY=https://goproxy.cn,direct
  12. # 安装 gentool
  13. echo "📦 正在安装 gentool..."
  14. if ! go install gorm.io/gen/tools/gentool@latest; then
  15. echo "❌ gentool 安装失败"
  16. exit 1
  17. fi
  18. # 验证 gentool 安装是否成功
  19. if command -v gentool >/dev/null 2>&1; then
  20. echo "✅ gentool 安装成功"
  21. else
  22. echo "❌ gentool 安装失败"
  23. exit 1
  24. fi
  25. fi