randomKit

package module
v0.0.0-...-4e18145 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: MIT Imports: 8 Imported by: 2 modules, 1 package

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

This section is empty.

Variables

View Source
var (

	// BaseNumber 用于随机选的数字
	BaseNumber = "0123456789"
	// BaseChar 用于随机选的字符
	BaseChar = "abcdefghijklmnopqrstuvwxyz"
	// BaseUpperCaseChar 用于随机选的大写字符
	BaseUpperCaseChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	// BaseCharNumber 用于随机选的字符和数字
	BaseCharNumber = fmt.Sprintf("%v%v", BaseChar, BaseNumber)
	// BaseAllChar 用于随机选的字符、数字和大写字符
	BaseAllChar = fmt.Sprintf("%v%v%v", BaseChar, BaseNumber, BaseUpperCaseChar)
)

Functions

func RandomBool

func RandomBool() bool

RandomBool 获得随机Boolean值 *

  • @return 随机Boolean值

func RandomInt

func RandomInt(min, max int) int

RandomInt 获得指定范围内的随机数[min, max) *

  • @param min 最小数(包含)
  • @param max 最大数(不包含)
  • @return 随机数

func RandomLong

func RandomLong(max int) int

RandomLong 返回一个介于0和max之间的int数:[0,max)。 注意: 1. max只能大于0,否则直接返回max; 2. 结果大于或等于0,但小于max; 3. 结果数字为32位,小于math. max32。 *

  • @param max 最大数(不包含)
  • @return 随机数

func RandomNumbers

func RandomNumbers(length int) string

RandomNumbers 获得一个只包含数字的字符串 *

  • @param length – 字符串的长度
  • @return 随机字符串

func RandomStr

func RandomStr(length int) string

RandomStr 随机字符串 *

  • @param length – 字符串的长度
  • @return 随机字符串

func RandomStrBasic

func RandomStrBasic(baseString string, length int) string

RandomStrBasic 获得一个随机的字符串 *

  • @param baseString 随机字符选取的样本
  • @param length 字符串的长度
  • @return 随机字符串

func RandomStringWithoutStr

func RandomStringWithoutStr(length int, elemData string) string

RandomStringWithoutStr 获得一个随机的字符串(只包含数字和字母) 并排除指定字符串 *

  • @param length – 字符串的长度
  • @param elemData – 要排除的字符串,如:去重容易混淆的字符串,oO0、lL1、q9Q、pP
  • @return 随机字符串

func RandomTradeNo

func RandomTradeNo(length int, isLetter bool) string

RandomTradeNo 创建订单号, 如果存在字母则字母为大写 *

  • @param length 长度(指排除YYYYMMDDHHmmss之后的长度)
  • @param isLetter 是否包含字母 true 允许字母| false 不允许字母
  • @return 订单号

Types

This section is empty.

Jump to

Keyboard shortcuts

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