str

package
v1.57.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: Apache-2.0 Imports: 17 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
)
View Source
var APP struct {
	Buffer      Buffer
	Rand        Rand
	Regexp      Regexp
	TerminalLog TerminalLog
	Str         Str
	Transfer    Transfer
	HTML        HTML
	Markdown    Markdown
}

Functions

func NewTemplate added in v1.57.1

func NewTemplate[T any](title, content string, s T) (string, error)

New 填充字符串

Types

type AttrHtmlA

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

func HtmlA

func HtmlA(name, href string, properties ...HtmlProperty) AttrHtmlA

func (AttrHtmlA) Register

func (my AttrHtmlA) Register(html *HTML)

type AttrHtmlAny

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

func HtmlAny

func HtmlAny(tag, content string) AttrHtmlAny

func (AttrHtmlAny) AppendProperties

func (my AttrHtmlAny) AppendProperties(properties ...HtmlProperty) AttrHtmlAny

func (AttrHtmlAny) Register

func (my AttrHtmlAny) Register(html *HTML)

type AttrHtmlBr

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

func HtmlBr

func HtmlBr() AttrHtmlBr

func (AttrHtmlBr) Register

func (my AttrHtmlBr) Register(html *HTML)

type AttrHtmlNormal

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

func HtmlNormal

func HtmlNormal(content string) AttrHtmlNormal

func (AttrHtmlNormal) Register

func (my AttrHtmlNormal) Register(html *HTML)

type AttrHtmlP

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

func HtmlP

func HtmlP(content string) AttrHtmlP

func (AttrHtmlP) Register

func (my AttrHtmlP) Register(html *HTML)

type AttrHtmlTBody

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

func HtmlTBody

func HtmlTBody(options ...HtmlAttributer) AttrHtmlTBody

func (AttrHtmlTBody) AppendProperties

func (my AttrHtmlTBody) AppendProperties(properties ...HtmlProperty) AttrHtmlTBody

func (AttrHtmlTBody) Register

func (my AttrHtmlTBody) Register(html *HTML)

type AttrHtmlTHead

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

func HtmlTHead

func HtmlTHead(options ...HtmlAttributer) AttrHtmlTHead

func (AttrHtmlTHead) AppendProperties

func (my AttrHtmlTHead) AppendProperties(properties ...HtmlProperty) AttrHtmlTHead

func (AttrHtmlTHead) Register

func (my AttrHtmlTHead) Register(html *HTML)

type AttrHtmlTable

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

func HtmlTable

func HtmlTable(options ...HtmlAttributer) AttrHtmlTable

func (AttrHtmlTable) AppendProperties

func (my AttrHtmlTable) AppendProperties(properties ...HtmlProperty) AttrHtmlTable

func (AttrHtmlTable) Register

func (my AttrHtmlTable) Register(html *HTML)

type AttrHtmlTd

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

func HtmlTd

func HtmlTd(content string) AttrHtmlTd

func (AttrHtmlTd) AppendProperties

func (my AttrHtmlTd) AppendProperties(properties ...HtmlProperty) AttrHtmlTd

func (AttrHtmlTd) Register

func (my AttrHtmlTd) Register(html *HTML)

type AttrHtmlTh

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

func HtmlTh

func HtmlTh(content string) AttrHtmlTh

func (AttrHtmlTh) AppendProperties

func (my AttrHtmlTh) AppendProperties(properties ...HtmlProperty) AttrHtmlTh

func (AttrHtmlTh) Register

func (my AttrHtmlTh) Register(html *HTML)

type AttrHtmlTr

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

func HtmlTr

func HtmlTr(options ...HtmlAttributer) AttrHtmlTr

func (AttrHtmlTr) AppendProperties

func (my AttrHtmlTr) AppendProperties(properties ...HtmlProperty) AttrHtmlTr

func (AttrHtmlTr) Register

func (my AttrHtmlTr) Register(html *HTML)

type AttrHtmlUl

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

func HtmlUl

func HtmlUl(contents ...string) AttrHtmlUl

func (AttrHtmlUl) Register

func (my AttrHtmlUl) Register(html *HTML)

type AttrMarkdownA

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

func MarkdownA

func MarkdownA(name, href string) AttrMarkdownA

func (AttrMarkdownA) Register

func (my AttrMarkdownA) Register(markdown *Markdown)

type AttrMarkdownBr

type AttrMarkdownBr struct{}

func MarkdownBr

func MarkdownBr() AttrMarkdownBr

func (AttrMarkdownBr) Register

func (AttrMarkdownBr) Register(markdown *Markdown)

type AttrMarkdownNormal

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

func MarkdownNormal

func MarkdownNormal(content string) AttrMarkdownNormal

func (AttrMarkdownNormal) Register

func (my AttrMarkdownNormal) Register(markdown *Markdown)

type AttrMarkdownOl

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

func MarkdownOl

func MarkdownOl(contents ...string) AttrMarkdownOl

func (AttrMarkdownOl) Append

func (my AttrMarkdownOl) Append(contents ...string) AttrMarkdownOl

func (AttrMarkdownOl) Register

func (my AttrMarkdownOl) Register(markdown *Markdown)

type AttrMarkdownUl

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

func MarkdownUl

func MarkdownUl(contents ...string) AttrMarkdownUl

func (AttrMarkdownUl) Append

func (my AttrMarkdownUl) Append(contents ...string) AttrMarkdownUl

func (AttrMarkdownUl) Register

func (my AttrMarkdownUl) Register(markdown *Markdown)

type AttrRegexpTargetError

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

func RegexpTargetError

func RegexpTargetError(target error) AttrRegexpTargetError

func (AttrRegexpTargetError) Register

func (my AttrRegexpTargetError) Register(regexp *Regexp)

type AttrRegexpTargetString

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

func RegexpTargetString

func RegexpTargetString(target string) AttrRegexpTargetString

func (AttrRegexpTargetString) Register

func (my AttrRegexpTargetString) Register(regexp *Regexp)

type AttrRegexpTargetsError

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

func RegexpTargetsError

func RegexpTargetsError(targets ...error) AttrRegexpTargetsError

func (AttrRegexpTargetsError) Register

func (my AttrRegexpTargetsError) Register(regexp *Regexp)

type AttrRegexpTargetsString

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

func RegexpTargetsString

func RegexpTargetsString(targets ...string) AttrRegexpTargetsString

func (AttrRegexpTargetsString) Register

func (my AttrRegexpTargetsString) Register(regexp *Regexp)

type Buffer

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

func (Buffer) Any

func (my Buffer) Any(values ...any) Buffer

Any 追加任意内容到字符串

func (Buffer) B

func (my Buffer) B(values ...byte) Buffer

B 追加写入字节

func (Buffer) Bytes

func (my Buffer) Bytes() []byte

Bytes 获取字节码

func (Buffer) Copy

func (my Buffer) Copy() Buffer

Copy 复制当前对象

func (Buffer) JoinAny

func (Buffer) JoinAny(values ...any) string

func (Buffer) JoinAnyLimit

func (Buffer) JoinAnyLimit(limit string, values ...any) string

func (Buffer) JoinString

func (Buffer) JoinString(strings ...string) string

func (Buffer) JoinStringLimit

func (Buffer) JoinStringLimit(limit string, strings ...string) string

func (Buffer) NewAny

func (Buffer) NewAny(data ...any) Buffer

func (Buffer) NewBytes

func (Buffer) NewBytes(original []byte) Buffer

NewBytes 实例化:通过字节码

func (Buffer) NewRune

func (Buffer) NewRune(data ...rune) Buffer

NewRune 实例化:通过字符

func (Buffer) NewString

func (Buffer) NewString(data ...string) Buffer

NewString 实例化:通过字符串

func (Buffer) Ptr

func (my Buffer) Ptr() *string

Ptr 获取字符串指针

func (Buffer) R

func (my Buffer) R(values ...rune) Buffer

R 追加写入字符

func (Buffer) S

func (my Buffer) S(values ...string) Buffer

S 追加写入字符串

func (Buffer) Sha256Sum256

func (my Buffer) Sha256Sum256() string

func (Buffer) String

func (my Buffer) String() string

String 获取字符串

func (Buffer) URLPath added in v1.53.4

func (my Buffer) URLPath(values ...string) Buffer

URLPath 字符串 -> 追加写入 URL 路径

func (Buffer) URLQuery added in v1.53.4

func (my Buffer) URLQuery(values ...string) Buffer

URLQuery 字符串 -> 追加写入 URL 查询

func (Buffer) WhenB added in v1.56.7

func (my Buffer) WhenB(condition bool, values ...byte) Buffer

func (Buffer) WhenR added in v1.56.7

func (my Buffer) WhenR(condition bool, values ...rune) Buffer

func (Buffer) WhenS added in v1.56.7

func (my Buffer) WhenS(condition bool, values ...string) Buffer

type HTML added in v1.53.5

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

func (HTML) End added in v1.53.5

func (my HTML) End() string

func (HTML) New added in v1.53.5

func (HTML) New(options ...HtmlAttributer) HTML

func (HTML) NewString added in v1.53.5

func (HTML) NewString(options ...HtmlAttributer) string

func (HTML) Set added in v1.53.5

func (my HTML) Set(options ...HtmlAttributer) HTML

type HtmlAttributer

type HtmlAttributer interface{ Register(html *HTML) }

type HtmlProperty

type HtmlProperty struct {
	Key   string
	Value string
}

type Markdown

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

func (Markdown) End

func (my Markdown) End() string

func (Markdown) New

func (Markdown) New(options ...MarkdownAttributer) Markdown

func (Markdown) NewString

func (Markdown) NewString(options ...MarkdownAttributer) string

func (Markdown) Set

func (my Markdown) Set(options ...MarkdownAttributer) Markdown

type MarkdownAttributer

type MarkdownAttributer interface {
	Register(markdown *Markdown)
}

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 Regexp

type Regexp struct {
	// contains filtered or unexported fields
}
var (
	RegexpApp Regexp
)

func (Regexp) Contains

func (my Regexp) Contains() bool

Contains 是否包含匹配项

func (Regexp) ContainsAll

func (my Regexp) ContainsAll() bool

ContainsAll 是否包含任意一个匹配项

func (Regexp) MatchAll

func (my Regexp) MatchAll() []string

MatchAll 查找所有匹配项

func (Regexp) MatchFirst

func (my Regexp) MatchFirst() string

MatchFirst 查找第一个匹配项

func (Regexp) New

func (Regexp) New(original string, attrs ...RegexpRegexpAttributer) Regexp

func (Regexp) ReplaceAllString

func (my Regexp) ReplaceAllString(replace string) string

ReplaceAllString 替换所有匹配项

func (Regexp) Set

func (my Regexp) Set(attrs ...RegexpRegexpAttributer) Regexp

type RegexpRegexpAttributer

type RegexpRegexpAttributer interface{ Register(regexp *Regexp) }

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 后置补零

func (*Str) ToLong

func (my *Str) ToLong(length int, ends ...string) string

ToLong 超出长度截断

type Template added in v1.57.1

type Template[T any] struct{}

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

CamelToBabel 小驼峰 -> 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

SnakeToCamel 下划线 -> 小驼峰

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