Skip to content

Commit e75a1a7

Browse files
committed
substr
1 parent 8797fdb commit e75a1a7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

helpers.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,10 @@ func SnakeCase(in string) string {
110110

111111
return strings.Replace(string(out), "__", "_", -1)
112112
}
113+
114+
func Substring(str string, length int) string {
115+
if len(str) > length {
116+
return strings.Join(strings.Split(str, "")[:length], "")
117+
}
118+
return str
119+
}

0 commit comments

Comments
 (0)