Browse Source

[upd] utils

ksuid v0.2.26
loveckiy.ivan 2 months ago
parent
commit
703edfbaeb
  1. 8
      utils.go

8
utils.go

@ -6,8 +6,8 @@ import "strings"
// opt0 - сколько символов оставить сначала строки (по-умолчанию 3)
// opt1 - сколько символов оставить в конце строки (по-умолчанию 3)
func HideExceptFirstAndLast(str string, opt ...int) string {
prefCount := 3
postCount := 3
prefCount := 1
postCount := 1
if len(opt) > 0 {
prefCount = opt[0]
@ -29,5 +29,9 @@ func HideExceptFirstAndLast(str string, opt ...int) string {
builder.WriteString("*")
}
}
if builder.Len() > 16 {
return builder.String()[:15]
}
return builder.String()
}

Loading…
Cancel
Save