MCPcopy Create free account
hub / github.com/goadesign/goa / CamelCase

Function CamelCase

codegen/funcs.go:105–120  ·  view source on GitHub ↗

CamelCase produces the CamelCase version of the given string. It removes any non letter and non digit character. If firstUpper is true the first letter of the string is capitalized else the first letter is in lowercase. If acronym is true and a part of the string is a common acronym then it keeps

(name string, firstUpper, acronym bool)

Source from the content-addressed store, hash-verified

103// then it keeps the part capitalized (firstUpper = true)
104// (e.g. APIVersion) or lowercase (firstUpper = false) (e.g. apiVersion).
105func CamelCase(name string, firstUpper, acronym bool) string {
106 if name == "" {
107 return ""
108 }
109
110 // Use cache to avoid recomputing the same transformation
111 key := cacheKey{
112 input: name,
113 firstUpper: firstUpper,
114 acronym: acronym,
115 operation: "camel",
116 }
117 return globalStringCache.getCached(key, func() string {
118 return camelCaseUncached(name, firstUpper, acronym)
119 })
120}
121
122// camelCaseUncached is the original implementation without caching.
123func camelCaseUncached(name string, firstUpper, acronym bool) string {

Callers 5

protoBufifyFunction · 0.92
fixReservedProtoBufFunction · 0.92
attributeNameFunction · 0.92
GoifyFunction · 0.85
TestCamelCaseFunction · 0.85

Calls 2

camelCaseUncachedFunction · 0.85
getCachedMethod · 0.80

Tested by 1

TestCamelCaseFunction · 0.68