#!/bin/bash

echo "📦 开始安装股票分析工具..."

# 检查 Go 是否安装
if ! command -v go &> /dev/null; then
    echo "❌ 未检测到 Go，请先安装 Go 1.21+"
    echo "下载地址: https://go.dev/dl/"
    exit 1
fi

echo "✅ Go 版本: $(go version)"

# 进入项目目录
cd "$(dirname "$0")"

# 下载依赖
echo "📥 下载 Go 依赖..."
go mod download

# 编译程序
echo "🔨 编译程序..."
go build -o stock-tool main.go

# 创建数据目录
mkdir -p data

echo "✅ 安装完成！"
echo ""
echo "📋 运行程序:"
echo "  ./stock-tool"
echo ""
echo "📋 或者直接运行:"
echo "  go run main.go"
echo ""
echo "🌐 访问网页:"
echo "  http://localhost:8080"
