MCPcopy Create free account
hub / github.com/zeromicro/go-zero / ToSnake

Method ToSnake

tools/goctl/util/stringx/string.go:76–83  ·  view source on GitHub ↗

ToSnake converts the input text into snake case

()

Source from the content-addressed store, hash-verified

74
75// ToSnake converts the input text into snake case
76func (s String) ToSnake() string {
77 list := s.splitBy(unicode.IsUpper, false)
78 var target []string
79 for _, item := range list {
80 target = append(target, From(item).Lower())
81 }
82 return strings.Join(target, "_")
83}
84
85// Untitle return the original string if rune is not letter at index 0
86func (s String) Untitle() string {

Callers 4

SnakeMethod · 0.80
generateCustomModelFunction · 0.80
TestString_Camel2SnakeFunction · 0.80
FormatFilenameFunction · 0.80

Calls 4

splitByMethod · 0.95
JoinMethod · 0.80
FromFunction · 0.70
LowerMethod · 0.45

Tested by 1

TestString_Camel2SnakeFunction · 0.64