Skip to content
Snippets Groups Projects
Commit ac0b526b authored by Francé Wilke's avatar Francé Wilke
Browse files

Add function `LimitStringToMaxLength`

parent 7223ecab
No related branches found
No related tags found
No related merge requests found
...@@ -287,3 +287,10 @@ func IsUrlStrict(str string) bool { ...@@ -287,3 +287,10 @@ func IsUrlStrict(str string) bool {
u, err := url.Parse(str) u, err := url.Parse(str)
return err == nil && u.Scheme != "" && u.Host != "" return err == nil && u.Scheme != "" && u.Host != ""
} }
func LimitStringToMaxLength(str string, maxLen int) string {
if len(str) > maxLen {
str = str[0:maxLen]
}
return str
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment