mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
30 lines
415 B
Go
30 lines
415 B
Go
package util
|
|
|
|
import "strings"
|
|
|
|
func StringSliceContains(slice []string, needle string) bool {
|
|
for _, s := range slice {
|
|
if s == needle {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func MaskKey(key string) string {
|
|
if len(key) == 0 {
|
|
return "{empty}"
|
|
}
|
|
|
|
h := len(key) / 3
|
|
if h > 5 {
|
|
h = 5
|
|
}
|
|
|
|
maskKey := key[0:h]
|
|
maskKey += strings.Repeat("*", len(key)-h*2)
|
|
maskKey += key[len(key)-h:]
|
|
return maskKey
|
|
}
|