Initial commit for ClawGo

This commit is contained in:
DBT
2026-02-12 02:57:27 +00:00
commit 4956b1a014
60 changed files with 9991 additions and 0 deletions

26
pkg/utils/utils.go Normal file
View File

@@ -0,0 +1,26 @@
package utils
import (
"encoding/json"
"fmt"
)
// PrettyPrint prints a data structure as a pretty JSON string.
func PrettyPrint(v interface{}) {
b, err := json.MarshalIndent(v, "", " ")
if err != nil {
fmt.Println("error:", err)
}
fmt.Println(string(b))
}
// Truncate returns a truncated version of s with at most maxLen characters.
func Truncate(s string, maxLen int) string {
if len(s) <= maxLen {
return s
}
if maxLen <= 3 {
return s[:maxLen]
}
return s[:maxLen-3] + "..."
}