util

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 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 IPMatchPrefix = PrefixDecorator(defaultPrefix, IPMatch)
View Source
var PathMatchFunc = WrapMatchingFunc(PathMatch)
View Source
var PathMatchFunc2 = WrapMatchingFunc(PathMatch2)
View Source
var RegexMatchFunc = WrapMatchingFunc(RegexMatch)
View Source
var RegexMatchPrefix = PrefixDecorator(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 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 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 MatchingFunc

type MatchingFunc func(str, pattern string) bool

func PrefixDecorator

func PrefixDecorator(prefix string, fn MatchingFunc) MatchingFunc

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