From 9649167c83cf1d9871d3e7774fc2d2ca4979a2d5 Mon Sep 17 00:00:00 2001 From: "Logan.Li" Date: Fri, 26 Jun 2026 11:09:58 +0800 Subject: [PATCH] =?UTF-8?q?run.sh:=20=E9=9D=9E=E4=BA=A4=E4=BA=92=20shell?= =?UTF-8?q?=20=E8=87=AA=E5=8A=A8=E8=A1=A5=E5=85=85=20Go=20PATH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/run.sh b/run.sh index aab3883..90da7ae 100755 --- a/run.sh +++ b/run.sh @@ -121,6 +121,7 @@ rotate_log() { # 后端服务(本地开发模式) # ============================================================ start_backend() { + ensure_go_path || return 1 info "启动后端服务..." cd "$SCRIPT_DIR/$BACKEND_DIR" mkdir -p logs @@ -411,8 +412,21 @@ websocket: YAML } +# 非交互 shell 常缺 Go PATH,补充常见安装目录 // Logan.Li +ensure_go_path() { + if command -v go &>/dev/null; then + return 0 + fi + export PATH="/usr/local/go/bin:$HOME/go/bin:/usr/lib/go/bin:$PATH" + if ! command -v go &>/dev/null; then + error "Go 未安装或不在 PATH,请先安装 Go 1.24+" + return 1 + fi +} + # 编译独立二进制(含 embed 前端)// Logan.Li build_standalone_binary() { + ensure_go_path || return 1 build_frontend_embed ensure_binary_config clean_go_artifacts