MCPcopy Index your code
hub / github.com/coder/coder / truncateRunes

Function truncateRunes

coderd/x/chatd/chattool/chattool.go:120–133  ·  view source on GitHub ↗
(value string, maxLen int)

Source from the content-addressed store, hash-verified

118}
119
120func truncateRunes(value string, maxLen int) string {
121 if maxLen <= 0 || value == "" {
122 return ""
123 }
124 if utf8.RuneCountInString(value) <= maxLen {
125 return value
126 }
127
128 runes := []rune(value)
129 if maxLen > len(runes) {
130 maxLen = len(runes)
131 }
132 return string(runes[:maxLen])
133}
134
135// buildErrorResult is a structured error response that preserves
136// the build ID alongside the error message. This lets the frontend

Callers 2

ReadTemplateFunction · 0.70
ListTemplatesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected