@echo off
setlocal EnableExtensions
cd /d "%~dp0"

REM 一键交叉编译 Linux amd64，供 Dockerfile.prebuilt 直接 COPY dist\server（服务器上无需再 go build）
if not exist "dist" mkdir "dist"

set "CGO_ENABLED=0"
set "GOOS=linux"
set "GOARCH=amd64"
set "GOTOOLCHAIN=auto"

echo [build-linux-amd64] GOOS=%GOOS% GOARCH=%GOARCH% GOTOOLCHAIN=%GOTOOLCHAIN%
go build -trimpath -ldflags="-s -w" -o "dist\server" .\cmd\server
if errorlevel 1 (
  echo [build-linux-amd64] FAILED
  exit /b 1
)

echo [build-linux-amd64] OK: dist\server
exit /b 0
