630 B
630 B
| paths | |||
|---|---|---|---|
|
Go 安全性 (Security)
本檔案擴展了 common/security.md,包含 Go 特定內容。
金鑰管理 (Secret Management)
apiKey := os.Getenv("OPENAI_API_KEY")
if apiKey == "" {
log.Fatal("OPENAI_API_KEY not configured")
}
安全掃描 (Security Scanning)
- 使用 gosec 進行靜態安全分析:
gosec ./...
上下文 (Context) 與 逾時 (Timeouts)
始終使用 context.Context 進行逾時控制:
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()