MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / LowercaseFirstCharacters

Function LowercaseFirstCharacters

pkg/codegen/utils.go:203–220  ·  view source on GitHub ↗

Lowercase the first upper characters in a string for case of abbreviation. This assumes UTF-8, so we have to be careful with unicode, don't treat it as a byte array.

(str string)

Source from the content-addressed store, hash-verified

201// Lowercase the first upper characters in a string for case of abbreviation.
202// This assumes UTF-8, so we have to be careful with unicode, don't treat it as a byte array.
203func LowercaseFirstCharacters(str string) string {
204 if str == "" {
205 return ""
206 }
207
208 runes := []rune(str)
209
210 for i := range runes {
211 next := i + 1
212 if i != 0 && next < len(runes) && unicode.IsLower(runes[next]) {
213 break
214 }
215
216 runes[i] = unicode.ToLower(runes[i])
217 }
218
219 return string(runes)
220}
221
222// ToCamelCase will convert query-arg style strings to CamelCase. We will
223// use `., -, +, :, ;, _, ~, ' ', (, ), {, }, [, ]` as valid delimiters for words.

Callers 2

GoVariableNameMethod · 0.85

Calls

no outgoing calls

Tested by 1