nightingale/pkg/istr/checker.go

25 lines
335 B
Go
Raw Normal View History

package istr
import (
2021-07-16 23:30:09 +08:00
"strconv"
2021-07-16 23:46:11 +08:00
"strings"
)
func SampleKeyInvalid(str string) bool {
idx := strings.IndexFunc(str, func(r rune) bool {
return r == '\t' ||
r == '\r' ||
r == '\n' ||
r == ',' ||
r == ' ' ||
r == '='
})
2021-07-16 23:30:09 +08:00
if idx != -1 {
return true
}
_, err := strconv.ParseFloat(str, 64)
return err == nil
}