Documentation ¶
Index ¶
- type RegexpMap
- func (m *RegexpMap) Add(reStr string, lookupValue string) error
- func (m *RegexpMap) GetPrecompiledRegexp(reStr string) (re *regexp.Regexp)
- func (m *RegexpMap) LookupContainsValue(lookupKey, expectedValue string) (found bool)
- func (m *RegexpMap) LookupValues(lookupKey string) (lookupValues []string)
- func (m *RegexpMap) Remove(reStr, lookupValue string) (deleted bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RegexpMap ¶
type RegexpMap struct {
// contains filtered or unexported fields
}
RegexpMap is a map-like type that allows lookups to match regexp keys. These keys are managed internally as strings, and are uniqued by this representation (and not recompiled on repeat inserts). Stored values are strings and are returned as-is, with the exception that repeat inserts of the same value are de-duped. Note: RegexpMap is not thread-safe and managing concurrent access is the responsibility of the callers.
func (*RegexpMap) Add ¶
Add associates lookupValue as a return value for reStr on lookup Repeated calls with the same reStr will not recompile the regexp, but will store all lookupValues in a set
func (*RegexpMap) GetPrecompiledRegexp ¶
GetPrecompiledRegexp returns the regexp matching reStr if it is in the map. This is a utility function to avoid recompiling regexps repeatedly, and the RegexpMap keeps the refcount for us.
func (*RegexpMap) LookupContainsValue ¶
LookupContainsValue returns true if any reStr in lookups, inserted via Add, matches lookupKey AND has a lookupValue, inserted via the same Add, that matches expectedValue.
func (*RegexpMap) LookupValues ¶
LookupValues returns all lookupValues, inserted via Add, where the reStr matches lookupKey