Documentation ¶
Index ¶
- Variables
- func HiddenStr(origin string, opts ...hiddenStrOption) string
- func HiddenStrHead(origin string, length int, opts ...hiddenStrOption) string
- func HiddenStrLength(length uint) hiddenStrOption
- func HiddenStrStart(start uint) hiddenStrOption
- func HiddenStrSymbol(symbol string) hiddenStrOption
- func HiddenStrTail(origin string, length int, opts ...hiddenStrOption) string
- func NewSeg(dictDir string) (err error)
- func RandomOptionCustomSeed(seed string) randomOption
- func RandomOptionLength(length uint) randomOption
- func RandomOptionLetter() randomOption
- func RandomOptionLower() randomOption
- func RandomOptionNumber() randomOption
- func RandomOptionUpper() randomOption
- func Repr(v any) string
- func SaltWithInt64Hex16(password string, i64 int64) string
- func SaltWithString(origin, slat string) string
- type AnyType
- type PlaceholderType
- type RandomResult
- type SegResult
- type Trie
- type TrieOption
Constants ¶
This section is empty.
Variables ¶
var Seg *seg
因为词典要加载到内容中,初始化时间有点长,这里用了一个全局变量,避免每次调用都初始化浪费时间
Functions ¶
func HiddenStrHead ¶
HiddenStrHead 从头部开始替换 Example: ReplaceStrTail("13800138000", 4) Out: ****0138000
func HiddenStrLength ¶
func HiddenStrLength(length uint) hiddenStrOption
HiddenStrLength 设置替换的长度, 默认是 4
func HiddenStrStart ¶
func HiddenStrStart(start uint) hiddenStrOption
HiddenStrStart 设置替换的开始位置,默认是 3
func HiddenStrSymbol ¶
func HiddenStrSymbol(symbol string) hiddenStrOption
HiddenStrSymbol 设置隐藏时的替换内容, 默认是 *
func HiddenStrTail ¶
HiddenStrTail 尾部开始隐藏 Example: HiddenStrTail("13800138000", 4) Out: 1380013****
func NewSeg ¶ added in v0.1.5
需要注意, 分词使用的 github.com/huichen/sego 这个库, 使用前***必须需要初始化*** 初始化的时候要将 data 目录中的 dict 复制到项目可以找到的地方, 并且在 NewSeg 的时候要制定 dict 目录 如: NewSeg(./data/dict)
func RandomOptionCustomSeed ¶ added in v0.1.5
func RandomOptionCustomSeed(seed string) randomOption
RandomOptionCustomSeed 设置自定义的随机数
func RandomOptionLength ¶
func RandomOptionLength(length uint) randomOption
RandomOptionLength 设置随机字符串长度
func SaltWithInt64Hex16 ¶ added in v0.1.4
SaltWithInt64Hex16 给密码加盐, 盐是 int64 格式的的数字转成 16 进制字符串
func SaltWithString ¶ added in v0.1.4
SaltWithString 加盐, 盐为字符串格式
Types ¶
type PlaceholderType ¶ added in v0.1.5
type PlaceholderType = struct{}
PlaceholderType represents a placeholder type.
var Placeholder PlaceholderType
Placeholder is a placeholder object that can be used globally.
type RandomResult ¶
type RandomResult []rune
随机字符串返回类型
func (RandomResult) Int ¶
func (b RandomResult) Int() int
ToInt 转成 int 类型, 不保证一定成功,要保证 seed 必须是纯数字,否则此处转换失败就是 0
func (RandomResult) String ¶
func (b RandomResult) String() string
type Trie ¶ added in v0.1.5
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 NewTrie ¶ added in v0.1.5
func NewTrie(words []string, opts ...TrieOption) Trie
NewTrie returns a Trie.
type TrieOption ¶ added in v0.1.5
type TrieOption func(trie *trieNode)
TrieOption defines the method to customize a Trie.
func WithMask ¶ added in v0.1.5
func WithMask(mask rune) TrieOption
WithMask customizes a Trie with keywords masked as given mask char.