operand-list.go: ToString() now can handle the Truncate option

This commit is contained in:
Celestino Amoroso 2024-05-20 05:30:26 +02:00
parent 554ff1a9dd
commit 82ec78719d

View File

@ -27,7 +27,7 @@ func newList(listAny []any) (list *ListType) {
return return
} }
func (ls *ListType) ToString(opt FmtOpt) string { func (ls *ListType) ToString(opt FmtOpt) (s string) {
var sb strings.Builder var sb strings.Builder
sb.WriteByte('[') sb.WriteByte('[')
if len(*ls) > 0 { if len(*ls) > 0 {
@ -55,7 +55,11 @@ func (ls *ListType) ToString(opt FmtOpt) string {
} }
} }
sb.WriteByte(']') sb.WriteByte(']')
return sb.String() s = sb.String()
if opt&Truncate != 0 && len(s) > TruncateSize {
s = TruncateString(s)
}
return
} }
func (ls *ListType) String() string { func (ls *ListType) String() string {