refactor: unify oneLineStr/oneLine into types.OneLine

provider.oneLineStr and gateway.oneLine had byte-identical bodies (flatten
whitespace + cap length). Move the single implementation into the types
package, which both layers already depend on, and delete both locals.
This commit is contained in:
dev
2026-08-24 22:26:51 +08:00
parent ef396f9b47
commit 5bb94db08c
3 changed files with 18 additions and 22 deletions

View File

@ -5,6 +5,7 @@ package types
import (
"encoding/json"
"errors"
"strings"
"time"
)
@ -159,4 +160,15 @@ type BuildMeta struct {
Source map[string]interface{} `json:"source"`
}
func Now() int64 { return time.Now().Unix() }
func Now() int64 { return time.Now().Unix() }
// OneLine flattens an error string to a single line capped at n chars.
// Shared by the provider layer (upstream error reasons) and the gateway
// layer (client-facing AUTO-chain summaries).
func OneLine(s string, n int) string {
s = strings.Join(strings.Fields(s), " ")
if len(s) > n {
s = s[:n] + "..."
}
return s
}