random

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Rand = rand.New(rand.NewSource(time.Now().UnixNano()))

Functions

func Float64s

func Float64s(length int) []float64

func Ints

func Ints(min int, max int, length int) []int

func Password added in v0.1.1

func Password(length int, otherChar string) string

Password 生成包含大写,小写,数字的字符串,以及指定特殊字符的密码

func Shuffle

func Shuffle[T IntUintStringFloat](t []T) []T

Shuffle 洗牌,打乱顺序

func ShuffleAny

func ShuffleAny(t []any) []any

ShuffleAny 洗牌,打乱顺序

func Slice

func Slice[T IntUintStringFloat](t []T, length int) []T

Slice 生成随机切片

func SliceAny

func SliceAny(t []any, length int) []any

SliceAny 生成随机切片

func String

func String(t TemplateString, length int) string

String 生成随机的字符串

Types

type IntUintStringFloat

type IntUintStringFloat interface {
	~int8 | ~int16 | ~int32 | ~int64 |
		~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~string |
		~float32 | ~float64
}

type TemplateString

type TemplateString string
const (
	TemplateString_0_9         TemplateString = `1234567890`
	TemplateString_a_z         TemplateString = `abcdefghijklmnopqrstuvwxyz`
	TemplateString_A_Z         TemplateString = `ABCDEFGHIJKLMNOPQRSTUVWXYZ`
	TemplateString_0_9_a_f     TemplateString = `1234567890abcdef`
	TemplateString_0_9_a_z     TemplateString = `1234567890abcdefghijklmnopqrstuvwxyz`
	TemplateString_0_9_A_F     TemplateString = `1234567890ABCDEF`
	TemplateString_0_9_A_Z     TemplateString = `1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ`
	TemplateString_a_z_A_Z     TemplateString = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`
	TemplateString_0_9_a_z_A_Z TemplateString = `1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`
)

Jump to

Keyboard shortcuts

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