fix: resolve go vet warnings for non-constant format strings

Replace log.Printf with log.Print for static strings to resolve
go vet warnings about non-constant format strings.

This is a security best practice as using Printf with dynamic strings
can lead to format string vulnerabilities.

Fixed 6 instances in trader/auto_trader.go:
- Line 260: Decision cycle separator (=)
- Line 262: Decision cycle separator (=)
- Line 349: System prompt separator (=)
- Line 353: System prompt separator (=)
- Line 357: CoT trace separator (-)
- Line 361: CoT trace separator (-)
This commit is contained in:
ZhouYongyou
2025-11-03 19:54:47 +08:00
parent 91fbe5bb4b
commit 492041cc20

View File

@@ -257,9 +257,9 @@ func (at *AutoTrader) Stop() {
func (at *AutoTrader) runCycle() error {
at.callCount++
log.Printf("\n" + strings.Repeat("=", 70))
log.Print("\n" + strings.Repeat("=", 70))
log.Printf("⏰ %s - AI决策周期 #%d", time.Now().Format("2006-01-02 15:04:05"), at.callCount)
log.Printf(strings.Repeat("=", 70))
log.Print(strings.Repeat("=", 70))
// 创建决策记录
record := &logger.DecisionRecord{
@@ -346,19 +346,19 @@ func (at *AutoTrader) runCycle() error {
// 打印系统提示词和AI思维链即使有错误也要输出以便调试
if decision != nil {
if decision.SystemPrompt != "" {
log.Printf("\n" + strings.Repeat("=", 70))
log.Print("\n" + strings.Repeat("=", 70))
log.Printf("📋 系统提示词 [模板: %s] (错误情况)", at.systemPromptTemplate)
log.Println(strings.Repeat("=", 70))
log.Println(decision.SystemPrompt)
log.Printf(strings.Repeat("=", 70) + "\n")
log.Print(strings.Repeat("=", 70) + "\n")
}
if decision.CoTTrace != "" {
log.Printf("\n" + strings.Repeat("-", 70))
log.Print("\n" + strings.Repeat("-", 70))
log.Println("💭 AI思维链分析错误情况:")
log.Println(strings.Repeat("-", 70))
log.Println(decision.CoTTrace)
log.Printf(strings.Repeat("-", 70) + "\n")
log.Print(strings.Repeat("-", 70) + "\n")
}
}