randx

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// TypeDigit 数字
	TypeDigit Type = 1
	// TypeLowerCase 小写字母
	TypeLowerCase Type = 1 << 1
	// TypeUpperCase 大写字母
	TypeUpperCase Type = 1 << 2
	// TypeSpecial 特殊符号
	TypeSpecial Type = 1 << 3
	// TypeMixed 混合类型
	TypeMixed = (TypeDigit | TypeUpperCase | TypeLowerCase | TypeSpecial)

	// CharsetDigit 数字字符组
	CharsetDigit = "0123456789"
	// CharsetLowerCase 小写字母字符组
	CharsetLowerCase = "abcdefghijklmnopqrstuvwxyz"
	// CharsetUpperCase 大写字母字符组
	CharsetUpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	// CharsetSpecial 特殊字符数组
	CharsetSpecial = " ~!@#$%^&*()_+-=[]{};'\\:\"|,./<>?"
)

Variables

This section is empty.

Functions

func RandCode

func RandCode(length int, typ Type) (string, error)

RandCode 根据传入的长度和类型生成随机字符串 请保证输入的 length >= 0,否则会返回 errLengthLessThanZero 请保证输入的 typ 的取值范围在 (0, type.MIXED] 内,否则会返回 errTypeNotSupported

func RandStrByCharset added in v0.0.9

func RandStrByCharset(length int, charset string) (string, error)

RandStrByCharset 根据传入的长度和字符集生成随机字符串 请保证输入的 length >= 0,否则会返回 errLengthLessThanZero 请保证输入的字符集不为空字符串,否则会返回 errTypeNotSupported 字符集内部字符可以无序或重复

Types

type Type added in v0.0.9

type Type int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL