Documentation ¶
Overview ¶
Package stdlib contains standard library functions exposed to River configs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Identifiers = map[string]interface{}{ "constants": constants, "env": os.Getenv, "concat": value.RawFunction(func(funcValue value.Value, args ...value.Value) (value.Value, error) { if len(args) == 0 { return value.Array(), nil } // finalSize is the final size of the resulting concatenated array. We type // check our arguments while computing what finalSize will be. var finalSize int for i, arg := range args { if arg.Type() != value.TypeArray { return value.Null, value.ArgError{ Function: funcValue, Argument: arg, Index: i, Inner: value.TypeError{ Value: arg, Expected: value.TypeArray, }, } } finalSize += arg.Len() } if len(args) == 1 { return args[0], nil } raw := make([]value.Value, 0, finalSize) for _, arg := range args { for i := 0; i < arg.Len(); i++ { raw = append(raw, arg.Index(i)) } } return value.Array(raw...), nil }), "json_decode": func(in string) (interface{}, error) { var res interface{} err := json.Unmarshal([]byte(in), &res) if err != nil { return nil, err } return res, nil }, }
Identifiers holds a list of stdlib identifiers by name. All interface{} values are River-compatible values.
Function identifiers are Go functions with exactly one non-error return value, with an optionally supported error return value as the second return value.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.