Documentation
¶
Index ¶
- Constants
- func ApplyTranslation(element interface{}, key, formatString string) (string, error)
- func AsString(value interface{}) (string, bool)
- func ExitOnError(err error, msg string)
- func FailOnError(err error, msg string)
- func FindStringSubmatchMap(re *regexp.Regexp, s string) map[string]string
- func FindStringSubmatchMapWithRegexExpression(re RegexExpression, s string) map[string]string
- func GetField(object interface{}, fieldPath string) (interface{}, error)
- func GetStringField(a interface{}, field string) string
- func NewID() string
- func ReadFile(path string) ([]byte, error)
- func StringInSlice(a string, list []string) bool
- type OptionalBool
- type OptionalInt64
- type OptionalInterface
- type OptionalRegexp
- type OptionalString
- type OptionalTemplate
- type RegexExpression
- type WrapperBuiltInRegex
- type WrapperRegex2
Constants ¶
const ( Regexp2MatchTimeout = "REGEXP2_MATCH_TIMEOUT" DefaultRegex2MatchTimeout = time.Second )
Variables ¶
This section is empty.
Functions ¶
func ApplyTranslation ¶
ApplyTranslation translate a templated string using informations in an Event
func AsString ¶
AsString tries to convert an interface{} into a string, and returns its value and an integer indicating whether it succeeded or not.
func ExitOnError ¶
ExitOnError calls log.Fatalf if err != nil
func FailOnError ¶
FailOnError calls log.Panicf if err != nil
func FindStringSubmatchMap ¶
FindStringSubmatchMap returns a map containing the values of the named subexpressions of the lefmost match of the regular expression re in s. A return value of nil indicates no match.
func FindStringSubmatchMapWithRegexExpression ¶
func FindStringSubmatchMapWithRegexExpression(re RegexExpression, s string) map[string]string
FindStringSubmatchMap returns a map containing the values of the named subexpressions of the lefmost match of the regular expression re in s. A return value of nil indicates no match.
func GetField ¶
GetField returns the value of a field of an object or a map, given the field's name as a string. Multiple field names may be chained, separated by dots:
GetField(alarm_value, "State.Value")
An error is returned if the field does not exist. If the field is a pointer, it will be dereferenced before being returned. Note that GetField cannot return map keys that contain a dot.
func GetStringField ¶
GetStringField read a string field in a struct, with introspection
func StringInSlice ¶
StringInSlice checks if a string is present in a list of strings
Types ¶
type OptionalBool ¶
type OptionalBool struct { // Set is a boolean indicating whether the value was set or not. Set bool // Value contains the value of the bool. It should only be taken into // account if Set is true. Value bool }
OptionalBool is a wrapper around bool that implements the bson.Setter interface.
Using this type instead of bool in a struct allows to :
- check whether the value was set or not in the bson document.
- raise an error when trying to unmarshal a value that is not an integer.
Note that when trying to unmarshal a value that is not a bool, SetBSON will raise an error that will not be handled by bson.Unmarshal. If this error is not handled in the SetBSON method of an ancestor, calls to MongoDB queries (e.g. mgo.Collection.Find) may fail.
type OptionalInt64 ¶
type OptionalInt64 struct { // Set is a boolean indicating whether the value was set or not. Set bool // Value contains the value of the int64. It should only be taken into // account if Set is true. Value int64 }
OptionalInt64 is a wrapper around int64 that implements the bson.Setter interface.
Using this type instead of int64 in a struct allows to :
- check whether the value was set or not in the bson document.
- raise an error when trying to unmarshal a value that is not an integer.
Note that when trying to unmarshal a value that is not an integer, SetBSON will raise an error that will not be handled by bson.Unmarshal. If this error is not handled in the SetBSON method of an ancestor, calls to MongoDB queries (e.g. mgo.Collection.Find) may fail.
type OptionalInterface ¶
type OptionalInterface struct { // Set is a boolean indicating whether the value was set or not. Set bool // Value contains the value of the interface{}. It should only be taken // into account if Set is true. Value interface{} }
OptionalInterface is a wrapper around interface{} that implements the bson.Setter interface.
Using this type instead of interface{} in a struct allows to check whether the value was set or not in the bson document.
type OptionalRegexp ¶
type OptionalRegexp struct { // Set is a boolean indicating whether the value was set or not. Set bool // Value contains the value of the regular expression. It should only be // taken into account if Set is true. Value RegexExpression }
OptionalRegexp is a wrapper around regexp.Regexp that implements the bson.Setter interface.
Using this type in a struct allows to :
- check whether the value was set or not in the bson document.
- automatically compile a regular expression.
- raise an error when trying to unmarshal a value that is not a valid regular expression.
Note that when trying to unmarshal a value that is not a valid regular expression, SetBSON will raise an error that will not be handled by bson.Unmarshal. If this error is not handled in the SetBSON method of an ancestor, calls to MongoDB queries (e.g. mgo.Collection.Find) may fail.
type OptionalString ¶
type OptionalString struct { // Set is a boolean indicating whether the value was set or not. Set bool // Value contains the value of the string. It should only be taken into // account if Set is true. Value string }
OptionalString is a wrapper around string that implements the bson.Setter interface.
Using this type instead of string in a struct allows to :
- check whether the value was set or not in the bson document.
- raise an error when trying to unmarshal a value that is not an integer.
Note that when trying to unmarshal a value that is not a string, SetBSON will raise an error that will not be handled by bson.Unmarshal. If this error is not handled in the SetBSON method of an ancestor, calls to MongoDB queries (e.g. mgo.Collection.Find) may fail.
type OptionalTemplate ¶
type OptionalTemplate struct { // Set is a boolean indicating whether the value was set or not. Set bool // Value contains the value of the regular expression. It should only be // taken into account if Set is true. Value *template.Template }
OptionalTemplate is a wrapper around template.Template that implements the bson.Setter interface.
Using this type in a struct allows to :
- check whether the value was set or not in the bson document.
- automatically compile a template.
- raise an error when trying to unmarshal a value that is not a valid template.
Note that when trying to unmarshal a value that is not a valid template, SetBSON will raise an error that will not be handled by bson.Unmarshal. If this error is not handled in the SetBSON method of an ancestor, calls to MongoDB queries (e.g. mgo.Collection.Find) may fail.
type RegexExpression ¶
func NewRegexExpression ¶
func NewRegexExpression(expr string) (RegexExpression, error)
type WrapperBuiltInRegex ¶
type WrapperRegex2 ¶
func (WrapperRegex2) Match ¶
func (r WrapperRegex2) Match(content []byte) bool