claude-code/claude-zh/commands/go-build.md

41 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# /go-build — 解決 Go 建置錯誤
自動診斷並修復 Go 專案中的編譯與建置錯誤。
## 使用方式
```bash
/go-build [目錄路徑]
```
## 功能說明
此指令會呼叫 **go-build-resolver** agent
1. **執行建置**:嘗試執行 `go build ./...``go install`
2. **分析日誌**:擷取並分類編譯錯誤訊息。
3. **定位問題**:找出錯誤的檔案與行號。
4. **自動修復**:常見修復範例包含:
- 匯入Import路徑不正確。
- 缺少變數、常數或類型定義。
- 接口Interface實作不完整。
- 型別不匹配。
- 語法錯誤(缺少分號、括號等)。
5. **依賴管理**:執行 `go mod tidy` 以解決缺少的問題。
## 修復策略
### 階段 1快速修復
針對匯入錯誤、拼字錯誤或缺少括號等簡單問題進行即時修正。
### 階段 2深度修復
針對類型定義變動或介面重構導致的連鎖錯誤進行分析與同步修復。
### 階段 3依賴修復
解決專案外部包Packages版本衝突或缺失問題。
## 注意事項
- 如果專案包含 CGO確保相關環境變數與連結庫已正確設定。
- 修復後會自動重新執行建置以驗證結果。
- 建議在提交重大變更前執行此指令以確保代碼可順利編譯。