fix golint issues in core/stringx (#516)

This commit is contained in:
Kevin Wan
2021-02-24 16:09:07 +08:00
committed by GitHub
parent acdaee0fb6
commit 04b0f26182
4 changed files with 23 additions and 2 deletions

View File

@@ -5,8 +5,10 @@ import "github.com/tal-tech/go-zero/core/lang"
const defaultMask = '*'
type (
// TrieOption defines the method to customize a Trie.
TrieOption func(trie *trieNode)
// A Trie is a tree implementation that used to find elements rapidly.
Trie interface {
Filter(text string) (string, []string, bool)
FindKeywords(text string) []string
@@ -23,6 +25,7 @@ type (
}
)
// NewTrie returns a Trie.
func NewTrie(words []string, opts ...TrieOption) Trie {
n := new(trieNode)
@@ -130,6 +133,7 @@ func (n *trieNode) replaceWithAsterisk(chars []rune, start, stop int) {
}
}
// WithMask customizes a Trie with keywords masked as given mask char.
func WithMask(mask rune) TrieOption {
return func(n *trieNode) {
n.mask = mask