util

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSep = ","

Variables

View Source
var IPMatchFunc = WrapMatchingFunc(IPMatch)
View Source
var PathMatchFunc = WrapMatchingFunc(PathMatch)
View Source
var PathMatchFunc2 = WrapMatchingFunc(PathMatch2)
View Source
var RegexMatchFunc = WrapMatchingFunc(RegexMatch)
View Source
var RegexMatcher = NewPrefixMatcher(defaultPrefix, RegexMatch)

Functions

func FileExists

func FileExists(path string) (bool, error)

func GlobMatch

func GlobMatch(key1 string, key2 string) (bool, error)

GlobMatch determines whether key1 matches the pattern of key2 using glob pattern

func GlobMatchFunc

func GlobMatchFunc(args ...interface{}) (interface{}, error)

GlobMatchFunc is the wrapper for GlobMatch.

func Hash

func Hash(rule []string) string

func IPMatch

func IPMatch(ip1 string, ip2 string) bool

IPMatch determines whether IP address ip1 matches the pattern of IP address ip2, ip2 can be an IP address or a CIDR pattern. For example, "192.168.2.123" matches "192.168.2.0/24"

func IsPathPattern added in v1.1.0

func IsPathPattern(path string) bool

func IsPathPattern2 added in v1.1.0

func IsPathPattern2(path string) bool

func IsPathPatternHelper added in v1.1.0

func IsPathPatternHelper(pattern, sep string, prefix, suffix byte) bool

func Join2D

func Join2D(elems [][]string, sep string) []string

func PathMatch

func PathMatch(path, pattern string) bool

func PathMatch2

func PathMatch2(path, pattern string) bool

func PathMatchHelper

func PathMatchHelper(path, pattern, sep string, prefix, suffix byte) bool

func RegexMatch

func RegexMatch(key1 string, key2 string) bool

RegexMatch determines whether key1 matches the pattern of key2 in regular expression.

func ValidateVariadicArgs

func ValidateVariadicArgs(expectedLen int, args ...interface{}) error

validate the variadic parameter size and type as string

Types

type IMatcher added in v1.1.0

type IMatcher interface {
	IsPattern(str string) bool
	Match(str, pattern string) bool
}

type LRUCache

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

func NewLRUCache

func NewLRUCache(capacity int) *LRUCache

func (*LRUCache) Get

func (cache *LRUCache) Get(key interface{}) (value interface{}, ok bool)

func (*LRUCache) Put

func (cache *LRUCache) Put(key interface{}, value interface{})

type Matcher added in v1.1.0

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

func NewMatcher added in v1.1.0

func NewMatcher(isPatternFn func(str string) bool, matchFn MatchingFunc) *Matcher

func (*Matcher) IsPattern added in v1.1.0

func (m *Matcher) IsPattern(str string) bool

func (*Matcher) Match added in v1.1.0

func (m *Matcher) Match(str, pattern string) bool

type MatchingFunc

type MatchingFunc func(str, pattern string) bool

type PrefixMatcher added in v1.1.0

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

func NewPrefixMatcher added in v1.1.0

func NewPrefixMatcher(prefix string, matchFn MatchingFunc) *PrefixMatcher

func (*PrefixMatcher) IsPattern added in v1.1.0

func (m *PrefixMatcher) IsPattern(str string) bool

func (*PrefixMatcher) Match added in v1.1.0

func (m *PrefixMatcher) Match(str, pattern string) bool

type SyncLRUCache

type SyncLRUCache struct {
	*LRUCache
	// contains filtered or unexported fields
}

func NewSyncLRUCache

func NewSyncLRUCache(capacity int) *SyncLRUCache

func (*SyncLRUCache) Get

func (cache *SyncLRUCache) Get(key interface{}) (value interface{}, ok bool)

func (*SyncLRUCache) Put

func (cache *SyncLRUCache) Put(key interface{}, value interface{})

Jump to

Keyboard shortcuts

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