MCPcopy Create free account
hub / github.com/Shelnutt2/db2struct / fmtFieldName

Function fmtFieldName

utils.go:110–123  ·  view source on GitHub ↗

fmtFieldName formats a string as a struct key Example: fmtFieldName("foo_id") Output: FooID

(s string)

Source from the content-addressed store, hash-verified

108// fmtFieldName("foo_id")
109// Output: FooID
110func fmtFieldName(s string) string {
111 name := lintFieldName(s)
112 runes := []rune(name)
113 for i, c := range runes {
114 ok := unicode.IsLetter(c) || unicode.IsDigit(c)
115 if i == 0 {
116 ok = unicode.IsLetter(c)
117 }
118 if !ok {
119 runes[i] = '_'
120 }
121 }
122 return string(runes)
123}
124
125func lintFieldName(name string) string {
126 // Fast path for simple cases: "_" and all lowercase.

Callers 1

generateMysqlTypesFunction · 0.85

Calls 1

lintFieldNameFunction · 0.85

Tested by

no test coverage detected