init: 提交 files 服务初始代码

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zxr
2026-08-03 23:51:21 +08:00
commit d29693343b
33 changed files with 2067 additions and 0 deletions

27
scripts/pack.ps1 Normal file
View File

@@ -0,0 +1,27 @@
# 保存调用进程的 Go 构建环境,脚本结束后恢复。
$hasGOOS = Test-Path Env:GOOS
$hasGOARCH = Test-Path Env:GOARCH
$hasGOFLAGS = Test-Path Env:GOFLAGS
$originalGOOS = $env:GOOS
$originalGOARCH = $env:GOARCH
$originalGOFLAGS = $env:GOFLAGS
Push-Location (Join-Path $PSScriptRoot '..')
try {
New-Item -ItemType Directory -Force -Path './build' | Out-Null
$env:GOOS = 'linux'
$env:GOARCH = 'amd64'
$env:GOFLAGS = '-buildvcs=false'
& go build -o './build/ops-files' './cmd/main/main.go'
if ($LASTEXITCODE -ne 0) {
throw "go build 失败,退出码:$LASTEXITCODE"
}
}
finally {
if ($hasGOOS) { $env:GOOS = $originalGOOS } else { Remove-Item Env:GOOS }
if ($hasGOARCH) { $env:GOARCH = $originalGOARCH } else { Remove-Item Env:GOARCH }
if ($hasGOFLAGS) { $env:GOFLAGS = $originalGOFLAGS } else { Remove-Item Env:GOFLAGS }
Pop-Location
}