123456789101112131415161718192021222324252627 |
- package utils
- import (
- "hash/crc32"
- "regexp"
- )
- func Rstrip(str string) string {
- if str == "" {
- return ""
- }
- //匹配一个或多个空白符的正则表达式
- reg := regexp.MustCompile("\\0+$")
- return reg.ReplaceAllString(str, "")
- }
- func Hash(s string) int {
- v := int(crc32.ChecksumIEEE([]byte(s)))
- if v >= 0 {
- return v
- }
- if -v >= 0 {
- return -v
- }
- // v == MinInt
- return 0
- }
|