Files
2026-05-16 19:19:39 +08:00

13 lines
568 B
PowerShell

$ErrorActionPreference = "Stop"
Set-Location $PSScriptRoot
New-Item -ItemType Directory -Force -Path dist | Out-Null
$env:CGO_ENABLED = "0"
$env:GOOS = "linux"
$env:GOARCH = "amd64"
$out = Join-Path $PSScriptRoot "dist\mengyaconnect-backend"
go build -trimpath -ldflags="-s -w" -o $out .
$b = [IO.File]::ReadAllBytes($out)
if ($b.Length -ge 4 -and $b[0] -eq 0x7F -and $b[1] -eq 0x45) { Write-Host "OK: Linux ELF amd64 -> $out" }
elseif ($b[0] -eq 0x4D -and $b[1] -eq 0x5A) { throw "Got Windows PE — check go env" }
else { throw "Unknown output format" }