MCPcopy Create free account
hub / github.com/chanced/caps / UpperFirstLowerRest

Function UpperFirstLowerRest

token/token.go:251–266  ·  view source on GitHub ↗

UpperFirstLowerRest title cases the first rune and lower cases the rest of s

(caser Caser, s string)

Source from the content-addressed store, hash-verified

249
250// UpperFirstLowerRest title cases the first rune and lower cases the rest of s
251func UpperFirstLowerRest(caser Caser, s string) string {
252 caser = CaserOrDefault(caser)
253 if len(s) == 0 {
254 return ""
255 }
256 b := strings.Builder{}
257 b.Grow(len(s))
258 for i, r := range s {
259 if i == 0 {
260 b.WriteRune(caser.ToTitle(r))
261 } else {
262 b.WriteRune(caser.ToLower(r))
263 }
264 }
265 return b.String()
266}
267
268// UpperFirst title cases the first rune of s
269func UpperFirst(caser Caser, s string) string {

Callers 2

FormatTokenFunction · 0.92
TestUpperFirstLowerRestFunction · 0.92

Calls 4

CaserOrDefaultFunction · 0.85
ToTitleMethod · 0.65
ToLowerMethod · 0.65
StringMethod · 0.45

Tested by 1

TestUpperFirstLowerRestFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…