str

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

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

	RandApp Rand
)
View Source
var (
	StrApp         Str
	TerminalLogApp TerminalLog
)

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}
var BufferApp Buffer

func (*Buffer) Byte

func (my *Buffer) Byte(byteList ...byte) *Buffer

func (*Buffer) NewByBytes

func (*Buffer) NewByBytes(original []byte) *Buffer

func (*Buffer) NewByString

func (*Buffer) NewByString(original string) *Buffer

func (*Buffer) Rune

func (my *Buffer) Rune(runeList ...rune) *Buffer

func (*Buffer) String

func (my *Buffer) String(stringList ...string) *Buffer

func (*Buffer) ToBytes

func (my *Buffer) ToBytes() []byte

func (*Buffer) ToString

func (my *Buffer) ToString() string

type Rand

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

func NewRand

func NewRand() *Rand

NewRand 实例化:随机字符串

func (*Rand) B

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

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

func (*Rand) D

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

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

func (*Rand) GetDigits

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

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

func (*Rand) GetLetters

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

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

func (*Rand) GetString

func (my *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

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

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

func (*Rand) Intn

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

func (*Rand) Meet

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

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

func (*Rand) MeetProb

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

MeetProb randomly calculate whether the given probability is met.

func (*Rand) N

func (my *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) New

func (*Rand) New() *Rand

func (*Rand) Perm

func (my *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

func (my *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

func NewStr(original string) *Str

NewStr 实例化:字符串

func (*Str) New

func (*Str) New(original string) *Str

func (*Str) PadLeft

func (my *Str) PadLeft(length int, s string) string

PadLeft 前置补充

func (*Str) PadLeftZeros

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

PadLeftZeros 前置补零

func (*Str) PadRight

func (my *Str) PadRight(length int, s string) string

PadRight 后置填充

func (*Str) PadRightZeros

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

PadRightZeros 后置补零

type TerminalLog

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

func NewTerminalLog

func NewTerminalLog(format ...string) *TerminalLog

NewTerminalLog 实例化:控制台日志

func (*TerminalLog) Default

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

Default 打印日志行

func (*TerminalLog) Error

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

Error 打印错误并终止程序

func (*TerminalLog) Info

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

Info 打印日志行

func (*TerminalLog) New

func (*TerminalLog) New(format ...string) *TerminalLog

New 实例化:控制台日志

func (*TerminalLog) Success

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

Success 打印成功

func (*TerminalLog) Wrong

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

Wrong 打印错误

type TerminalLogColor

type TerminalLogColor string
const (
	TerminalLogColorBlack   TerminalLogColor = "\033[30m"
	TerminalLogColorRed     TerminalLogColor = "\033[31m"
	TerminalLogColorGreen   TerminalLogColor = "\033[32m"
	TerminalLogColorYellow  TerminalLogColor = "\033[33m"
	TerminalLogColorBlue    TerminalLogColor = "\033[34m"
	TerminalLogColorMagenta TerminalLogColor = "\033[35m"
	TerminalLogColorCyan    TerminalLogColor = "\033[36m"
	TerminalLogColorWhite   TerminalLogColor = "\033[37m"
	TerminalLogColorReset   TerminalLogColor = "\033[0m"
)

type Transfer

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

func NewTransfer

func NewTransfer(original string) *Transfer

NewTransfer 实例化:字符串转换

func (*Transfer) BabelToPascal

func (my *Transfer) BabelToPascal() string

BabelToPascal babel -> 大驼峰

func (*Transfer) BabelToSnake

func (my *Transfer) BabelToSnake() string

BabelToSnake babel -> 下划线

func (*Transfer) CamelToBabel

func (my *Transfer) CamelToBabel() string

CamelToSnake 小驼峰 -> babel

func (*Transfer) CamelToPascal

func (my *Transfer) CamelToPascal() string

CamelToPascal 小驼峰 -> 大驼峰

func (*Transfer) CamelToSnake

func (my *Transfer) CamelToSnake() string

CamelToSnake 小驼峰 -> 下划线

func (*Transfer) KebabToCamel

func (my *Transfer) KebabToCamel() string

KebabToCamel babel -> 小驼峰

func (*Transfer) New

func (*Transfer) New(original string) *Transfer

func (*Transfer) PascalToBabel

func (my *Transfer) PascalToBabel() string

PascalToBabel 大驼峰 -> babel

func (*Transfer) PascalToCamel

func (my *Transfer) PascalToCamel() string

PascalToCamel 大驼峰 -> 小驼峰

func (*Transfer) PascalToSnake

func (my *Transfer) PascalToSnake() string

PascalToSnake 大驼峰 -> 下划线

func (*Transfer) Pluralize

func (my *Transfer) Pluralize() string

Pluralize 单数变复数

func (*Transfer) SnakeToBabel

func (my *Transfer) SnakeToBabel() string

SnakeToBabel 下划线 -> babel

func (*Transfer) SnakeToCamel

func (my *Transfer) SnakeToCamel() string

SnakeToPascal 下划线 -> 小驼峰

func (*Transfer) SnakeToPascal

func (my *Transfer) SnakeToPascal() string

SnakeToPascal 下划线 -> 大驼峰

Jump to

Keyboard shortcuts

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