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
|
|
|
|
}
|