mark2web/pkg/helper/string.go

17 lines
257 B
Go

package helper
// ShortenStringLeft shortens a string
func ShortenStringLeft(str string, num int) string {
if num <= 4 {
return ""
}
tstr := str
if len(str) > num {
if num > 3 {
num -= 3
}
tstr = "..." + str[len(str)-num:]
}
return tstr
}