MCPcopy
hub / github.com/sqlc-dev/sqlc / toSnakeCase

Function toSnakeCase

internal/codegen/golang/field.go:82–89  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

80var camelPattern = regexp.MustCompile("[^A-Z][A-Z]+")
81
82func toSnakeCase(s string) string {
83 if !strings.ContainsRune(s, '_') {
84 s = camelPattern.ReplaceAllStringFunc(s, func(x string) string {
85 return x[:1] + "_" + x[1:]
86 })
87 }
88 return strings.ToLower(s)
89}
90
91func toCamelCase(s string) string {
92 return toCamelInitCase(s, false)

Callers 2

SetCaseStyleFunction · 0.85
SetJSONCaseStyleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected