bstr

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package bstr 包是用来处理字符串相关的操作

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuilderOrderNoRandSize

func BuilderOrderNoRandSize(size uint, a ...string) string

创建订单号, 指定随机数长度,其实改上面函数就行,为了兼容已经使用了的代码,再写个新的吧

func IntToSha256

func IntToSha256(i int) string

IntToSha256 将传入的 int 加密成 sha256

func RandInt

func RandInt(length uint) (n int)

RandInt 获取纯数字的随机数

func RandLetter

func RandLetter(length uint) string

RandLetter 获取纯字符的随机字符串

func RandNumber

func RandNumber(length uint) string

RandNumber 获取纯数字的随机字符串

func Repr

func Repr(v any) string

Repr returns the string representation of v.

func ShowLess

func ShowLess(str string, opts ...int) string

ShowLess 字符串隐藏部分内容, 只显示较少的内容

func StrMd5UnixNano

func StrMd5UnixNano() string

StrMd5UnixNano 使用 unix nano 时间戳生成 md5 字符串

func StrSha256UnixNano

func StrSha256UnixNano() string

StrSha256UnixNano 使用 unix nano 时间戳生成 sha256 字符串, 长度 64

func StrToMd5

func StrToMd5(b string) string

func StrToSha256

func StrToSha256(b string) string

StrToSha256 将传入的字符串加密成 sha256

func StrUnixNanoNow

func StrUnixNanoNow() string

StrUnixNanoNow 将当前的 unix nano 时间转换成字符串

func StrUnixNow

func StrUnixNow() string

StrUnixNow 将当前的 unix 时间转换成字符串

func UUIDString

func UUIDString() string

UUIDString 创建基于 uuid 的字符串,去除 - 隔离符号

Types

type AnyType

type AnyType = any

AnyType can be used to hold any type.

type LetterStruct

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

LetterStruct Letter 结构

func NewRandLetter

func NewRandLetter() *LetterStruct

NewRandLetter 初始化 rLetter

func (*LetterStruct) OnlyLetters

func (ls *LetterStruct) OnlyLetters() *LetterStruct

OnlyLetters 设置生成随机数使用纯字母

func (*LetterStruct) OnlyNumber

func (ls *LetterStruct) OnlyNumber() *LetterStruct

OnlyNumber 设置生成随机数使用纯数字

func (*LetterStruct) RandProcess

func (ls *LetterStruct) RandProcess() ResultLetter

RandProcess 执行生成随机数的操作

func (*LetterStruct) SetLen

func (ls *LetterStruct) SetLen(length uint) *LetterStruct

SetLen 设置生成随机字符串的长度

func (*LetterStruct) SetLetters

func (ls *LetterStruct) SetLetters(letters string) *LetterStruct

SetLetters 设置生成随机数使用的字母

type PlaceholderType

type PlaceholderType = struct{}

PlaceholderType represents a placeholder type.

var Placeholder PlaceholderType

Placeholder is a placeholder object that can be used globally.

type ResultLetter

type ResultLetter string

ResultLetter 返回的数据类型

func (ResultLetter) ToInt

func (rl ResultLetter) ToInt() (int, error)

ToInt 返回值转换成 int 类型

func (ResultLetter) ToLower

func (rl ResultLetter) ToLower() string

ToLower 返回值转换成 string 类型, 并转转成小写

func (ResultLetter) ToString

func (rl ResultLetter) ToString() string

ToString 返回值转换成 string 类型

func (ResultLetter) ToUpper

func (rl ResultLetter) ToUpper() string

ToUpper 返回值转换成 string 类型, 并转转成大写

type Trie

type Trie interface {
	Filter(text string) (string, []string, bool)
	FindKeywords(text string) []string
}

A Trie is a tree implementation that used to find elements rapidly.

func DefaultTrie

func DefaultTrie() Trie

func NewTrie

func NewTrie(words []string, opts ...TrieOption) Trie

NewTrie returns a Trie.

type TrieOption

type TrieOption func(trie *trieNode)

TrieOption defines the method to customize a Trie.

func WithMask

func WithMask(mask rune) TrieOption

WithMask customizes a Trie with keywords masked as given mask char.

Jump to

Keyboard shortcuts

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