2026-03-03 17:25:38 +08:00
|
|
|
package utils
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/rs/xid"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// GenerateID 生成一个新的 ID (使用 xid,20位字符)
|
|
|
|
|
func GenerateID() string {
|
|
|
|
|
return xid.New().String()
|
|
|
|
|
}
|
2026-05-22 14:52:51 +08:00
|
|
|
|
2026-03-03 17:25:38 +08:00
|
|
|
// IsNumeric 检查字符串是否全为数字
|
|
|
|
|
func IsNumeric(s string) bool {
|
|
|
|
|
for _, c := range s {
|
|
|
|
|
if c < '0' || c > '9' {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return s != ""
|
|
|
|
|
}
|