Skip to content

Commit e68c5d7

Browse files
committed
did i make a change?
1 parent e75a1a7 commit e68c5d7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

helpers.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,26 @@ func SnakeCase(in string) string {
111111
return strings.Replace(string(out), "__", "_", -1)
112112
}
113113

114+
func SplitTitleCase(in string) string {
115+
out := titleCase(in, " ")
116+
return out
117+
}
118+
119+
func TitleCase(in string) string {
120+
out := titleCase(in, "")
121+
return out
122+
}
123+
124+
func titleCase(in string, sep string) string {
125+
out := SnakeCase(in)
126+
words := strings.Split(out, "_")
127+
for i, word := range words {
128+
words[i] = strings.Title(word)
129+
}
130+
out = strings.Join(words, sep)
131+
return out
132+
}
133+
114134
func Substring(str string, length int) string {
115135
if len(str) > length {
116136
return strings.Join(strings.Split(str, "")[:length], "")

0 commit comments

Comments
 (0)