Documentation
¶
Index ¶
- Constants
- func AlphabetLower(n int) string
- func Bool() bool
- func Element[T any](slice []T) T
- func Hex(n int) string
- func Int32Between(min, max int32) int32
- func Int64Between(min, max int64) int64
- func IntBetween(min, max int) int
- func Letter(size int) string
- func Name() string
- func NewRandHandler() *rand.Rand
- func Numeric(size int) string
- func NumericBetween(min, max int64) int64
- func OrderNo(randomSuffixLen int) string
- func Password(length int) string
- func Sample[T any](slice []T, n int) []T
- func SecureBase64URL(length int) (string, error)
- func SecureBytes(length int) ([]byte, error)
- func SecureHex(length int) (string, error)
- func SecureString(length int, charset string) (string, error)
- func SecureToken(length int) (string, error)
- func Shuffle[T any](slice []T)
- func String(n int, charset string) string
- func Strings(size int) string
- func Token(length int) string
- func TraceID() string
- func VerifyCode(length int) string
- func WeightedIndex(weights []int) int
Constants ¶
View Source
const ( CharsetLowercase = "abcdefghijklmnopqrstuvwxyz" CharsetAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" CharsetNumeral = "1234567890" CharsetHex = "1234567890abcdef" )
View Source
const ( CharsetAlphanumeric = CharsetAlphabet + CharsetNumeral CharsetUppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" CharsetSpecial = "!@#$%^&*()-_=+[]{}|;:,.<>?" CharsetPassword = CharsetAlphanumeric + "!@#$%^&*" )
扩展字符集常量
Variables ¶
This section is empty.
Functions ¶
func Int32Between ¶
Int32Between random number between min-max
func Int64Between ¶
Int64Between random number between min-max
func NewRandHandler ¶
NewRandHandler 创建随机数生成器 Deprecated: Go 1.20+ 全局 rand 已自动随机种子且并发安全,建议直接使用 rand 包全局函数
func NumericBetween ¶
NumericBetween random number between min-max
func SecureBase64URL ¶
SecureBase64URL 生成 URL 安全的 base64 token。 length 表示随机字节长度,不是最终字符串长度。
func SecureBytes ¶
SecureBytes 使用 crypto/rand 生成指定长度的安全随机字节。
func SecureString ¶
SecureString 使用 crypto/rand 从指定字符集中生成安全随机字符串。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.