開發與貢獻

從原始碼建置

給想修改 Watt 原始碼、或從自己的 checkout 執行開發版的開源貢獻者。

1. 準備工具鏈

Watt 目前以 Go 1.24.0 以上為建置需求,目標平台是 Windows amd64。建好的 watt.exe 不需要 Node.js、Python 或其他額外 runtime。

先從 GitHub repository fork 或 clone 原始碼,再進入 repository 根目錄:

PowerShell
git clone https://github.com/bext1998/WattCIAutomationEngine.git
Set-Location WattCIAutomationEngine

2. 安裝開發版

只想從目前公開原始碼安裝最新版本,可以使用 Go 的 module 安裝指令:

PowerShell
go install github.com/bext1998/WattCIAutomationEngine/cmd/watt@latest
watt --version

這會安裝 @latest 指定的版本;如果你要測試自己修改的 checkout,請使用下方的本機建置,或直接執行 go run ./cmd/watt。

3. 靜態建置 Windows binary

在 repository 根目錄用 Go 直接建置時,設定目標平台與 CGO_ENABLED=0,產出單一 dist\watt.exe:

PowerShell
$env:GOOS = "windows"
$env:GOARCH = "amd64"
$env:CGO_ENABLED = "0"
New-Item -ItemType Directory -Force .\dist | Out-Null
go build -trimpath -o .\dist\watt.exe .\cmd\watt
.\dist\watt.exe --version

若要使用 repository 已提供、會建立輸出目錄並在結束後還原建置環境變數的腳本:

PowerShell
.\scripts\build.ps1
.\dist\watt.exe --version
GOOS、GOARCH 與 CGO_ENABLED 的設定只為了這個 Windows amd64 靜態建置;執行上方的直接 go build 指令後,這些變數會保留在目前的 PowerShell session。想避免改動目前 session,請使用 .\scripts\build.ps1。

4. 修改後驗證

修改原始碼後,先執行既有的測試與靜態檢查,再確認建出的 binary:

PowerShell
go test ./...
go vet ./...
.\dist\watt.exe --version

想了解 repository 目錄與 package 職責,請閱讀 REPO_MAP.md;不要把網站上的操作摘要當成內部設計說明。

下一步

Watt 使用 MIT License。若要提交修改,請先閱讀 GitHub repository 的現有規範與 issue,再依專案流程提出 pull request。