MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / TruncateString

Function TruncateString

tsunami/util/util.go:289–295  ·  view source on GitHub ↗

TruncateString truncates a string to maxLen runes (not bytes). If the string is longer than maxLen, it truncates to maxLen-3 and appends "...".

(s string, maxLen int)

Source from the content-addressed store, hash-verified

287// TruncateString truncates a string to maxLen runes (not bytes).
288// If the string is longer than maxLen, it truncates to maxLen-3 and appends "...".
289func TruncateString(s string, maxLen int) string {
290 runes := []rune(s)
291 if len(runes) <= maxLen {
292 return s
293 }
294 return string(runes[0:maxLen-3]) + "..."
295}

Callers 2

SetAppMetaFunction · 0.92
SetShortDescFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected