str

package
v2.19.2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Letters      = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" // 52
	UpperLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"                           // 26
	LowerLetters = "abcdefghijklmnopqrstuvwxyz"                           // 26
	Symbols      = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"                   // 32
	Digits       = "0123456789"                                           // 10

)

Functions

This section is empty.

Types

type Rand added in v2.19.0

type Rand struct {
	// contains filtered or unexported fields
}

func NewRand added in v2.19.0

func NewRand() *Rand

func (*Rand) B added in v2.19.0

func (r *Rand) B(n int) []byte

B retrieves and returns random bytes of given length `n`.

func (*Rand) D added in v2.19.0

func (r *Rand) D(min, max time.Duration) time.Duration

D returns a random time.Duration between min and max: [min, max].

func (*Rand) GetDigits added in v2.19.0

func (r *Rand) GetDigits(n int) string

GetDigits returns a random str which contains only digits, and its length is `n`.

func (*Rand) GetLetters added in v2.19.0

func (r *Rand) GetLetters(n int) string

GetLetters returns a random str which contains only letters, and its length is `n`.

func (*Rand) GetString added in v2.19.0

func (r *Rand) GetString(s string, n int) string

GetString randomly picks and returns `n` count of chars from given str `s`. It also supports unicode str like Chinese/Russian/Japanese, etc.

func (*Rand) GetSymbols added in v2.19.0

func (r *Rand) GetSymbols(n int) string

GetSymbols returns a random str which contains only symbols, and its length is `n`.

func (*Rand) Intn added in v2.19.0

func (r *Rand) Intn(max int) int

func (*Rand) Meet added in v2.19.0

func (r *Rand) Meet(num, total int) bool

Meet randomly calculate whether the given probability `num`/`total` is met.

func (*Rand) MeetProb added in v2.19.0

func (r *Rand) MeetProb(prob float32) bool

MeetProb randomly calculate whether the given probability is met.

func (*Rand) N added in v2.19.0

func (r *Rand) N(min, max int) int

N returns a random int between min and max: [min, max]. The `min` and `max` also support negative numbers.

func (*Rand) Perm added in v2.19.0

func (r *Rand) Perm(n int) []int

Perm returns, as a slice of n int numbers, a pseudo-random permutation of the integers [0,n). TODO performance improving for large slice producing.

func (*Rand) S added in v2.19.0

func (r *Rand) S(n int, symbols ...bool) string

S returns a random str which contains digits and letters, and its length is `n`. The optional parameter `symbols` specifies whether the result could contain symbols, which is false in default.

type Str

type Str struct {
	// contains filtered or unexported fields
}

func NewStr added in v2.18.4

func NewStr(original string) *Str

func (*Str) PadLeftZeros

func (r *Str) PadLeftZeros(length int) (string, error)

PadLeftZeros 前置补零

func (*Str) PadRightZeros added in v2.18.4

func (r *Str) PadRightZeros(length int) (string, error)

PadRightZeros 后置补零

type TerminalLog added in v2.18.0

type TerminalLog struct {
	// contains filtered or unexported fields
}

func NewTerminalLog added in v2.18.0

func NewTerminalLog(format string) *TerminalLog

NewTerminalLog 实例化:控制台日志

func (*TerminalLog) Error added in v2.18.0

func (r *TerminalLog) Error(v ...any)

Error 打印错误并终止程序

func (*TerminalLog) Info added in v2.18.0

func (r *TerminalLog) Info(v ...any)

Info 打印日志行

func (*TerminalLog) Success added in v2.18.0

func (r *TerminalLog) Success(v ...any)

Success 打印成功

func (*TerminalLog) Wrong added in v2.18.2

func (r *TerminalLog) Wrong(v ...any)

Wrong 打印错误

type Transfer added in v2.18.0

type Transfer struct {
	// contains filtered or unexported fields
}

func NewTransfer added in v2.18.0

func NewTransfer(original string) *Transfer

func (*Transfer) BabelToPascal added in v2.18.0

func (r *Transfer) BabelToPascal() string

BabelToPascal babel -> 大驼峰

func (*Transfer) BabelToSnake added in v2.18.0

func (r *Transfer) BabelToSnake() string

BabelToSnake babel -> 下划线

func (*Transfer) CamelToBabel added in v2.18.0

func (r *Transfer) CamelToBabel() string

CamelToSnake 小驼峰 -> babel

func (*Transfer) CamelToPascal added in v2.18.0

func (r *Transfer) CamelToPascal() string

CamelToPascal 小驼峰 -> 大驼峰

func (*Transfer) CamelToSnake added in v2.18.0

func (r *Transfer) CamelToSnake() string

CamelToSnake 小驼峰 -> 下划线

func (*Transfer) KebabToCamel added in v2.18.0

func (r *Transfer) KebabToCamel() string

KebabToCamel babel -> 小驼峰

func (*Transfer) PascalToBabel added in v2.18.0

func (r *Transfer) PascalToBabel() string

PascalToSnake 大驼峰 -> babel

func (*Transfer) PascalToCamel added in v2.18.0

func (r *Transfer) PascalToCamel() string

PascalToCamel 大驼峰 -> 小驼峰

func (*Transfer) PascalToSnake added in v2.18.0

func (r *Transfer) PascalToSnake() string

PascalToSnake 大驼峰 -> 下划线

func (*Transfer) Pluralize added in v2.18.1

func (r *Transfer) Pluralize() string

Pluralize 单数变复数

func (*Transfer) SnakeToBabel added in v2.18.0

func (r *Transfer) SnakeToBabel() string

SnakeToBabel 下划线 -> babel

func (*Transfer) SnakeToCamel added in v2.18.0

func (r *Transfer) SnakeToCamel() string

SnakeToPascal 下划线 -> 小驼峰

func (*Transfer) SnakeToPascal added in v2.18.0

func (r *Transfer) SnakeToPascal() string

SnakeToPascal 下划线 -> 大驼峰

Jump to

Keyboard shortcuts

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