4efa383c57
We don't want to directly write to models so that only selected fields can be changed and values can be validated for security reasons. Signed-off-by: Michael Mayer <michael@liquidbytes.net>
18 lines
219 B
Go
18 lines
219 B
Go
package txt
|
|
|
|
import "strings"
|
|
|
|
func Clip(s string, size int) string {
|
|
if s == "" {
|
|
return ""
|
|
}
|
|
|
|
s = strings.TrimSpace(s)
|
|
runes := []rune(s)
|
|
|
|
if len(runes) > size {
|
|
s = string(runes[0 : size-1])
|
|
}
|
|
|
|
return s
|
|
}
|