mark2web/pkg/helper/string.go

17 lines
257 B
Go
Raw Normal View History

2019-03-25 14:01:28 +01:00
package helper
// ShortenStringLeft shortens a string
func ShortenStringLeft(str string, num int) string {
2019-03-25 15:33:53 +01:00
if num <= 4 {
return ""
}
2019-03-25 14:01:28 +01:00
tstr := str
if len(str) > num {
if num > 3 {
num -= 3
}
2022-02-28 10:27:32 +01:00
tstr = "..." + str[len(str)-num:]
2019-03-25 14:01:28 +01:00
}
return tstr
}