Documentation ¶
Index ¶
- Variables
- func Coalesce(_ *transformctx.Ctx, strs ...string) (string, error)
- func Concat(_ *transformctx.Ctx, strs ...string) (string, error)
- func DateTimeLayoutToRFC3339(_ *transformctx.Ctx, datetime, layout, layoutTZ, fromTZ, toTZ string) (string, error)
- func DateTimeToEpoch(_ *transformctx.Ctx, datetime, fromTZ, unit string) (string, error)
- func DateTimeToRFC3339(_ *transformctx.Ctx, datetime, fromTZ, toTZ string) (string, error)
- func EpochToDateTimeRFC3339(_ *transformctx.Ctx, epoch, unit string, tz ...string) (string, error)
- func Lower(_ *transformctx.Ctx, s string) (string, error)
- func Now(_ *transformctx.Ctx) (string, error)
- func UUIDv3(_ *transformctx.Ctx, s string) (string, error)
- func Upper(_ *transformctx.Ctx, s string) (string, error)
- type CustomFuncType
- type CustomFuncs
Constants ¶
This section is empty.
Variables ¶
var CommonCustomFuncs = map[string]CustomFuncType{ "coalesce": Coalesce, "concat": Concat, "dateTimeLayoutToRFC3339": DateTimeLayoutToRFC3339, "dateTimeToEpoch": DateTimeToEpoch, "dateTimeToRFC3339": DateTimeToRFC3339, "epochToDateTimeRFC3339": EpochToDateTimeRFC3339, "lower": Lower, "now": Now, "upper": Upper, "uuidv3": UUIDv3, }
CommonCustomFuncs contains the most basic and frequently-used custom functions that are suitable for all versions of schemas.
Functions ¶
func Coalesce ¶
func Coalesce(_ *transformctx.Ctx, strs ...string) (string, error)
Coalesce returns the first non-empty string of the input strings. If no input strings are given or all of them are empty, then empty string is returned. Note: a blank string (with only whitespaces) is not considered as empty.
func Concat ¶
func Concat(_ *transformctx.Ctx, strs ...string) (string, error)
Concat custom_func concatenates a number of strings together. If no strings specified, "" is returned.
func DateTimeLayoutToRFC3339 ¶
func DateTimeLayoutToRFC3339(_ *transformctx.Ctx, datetime, layout, layoutTZ, fromTZ, toTZ string) (string, error)
DateTimeLayoutToRFC3339 parses a 'datetime' string according a given 'layout' and normalizes and returns it in RFC3339 format. 'layoutTZ' specifies whether the 'layout' contains timezone info (such as tz offset, tz short names lik 'PST', or standard IANA tz long name, such as 'America/Los_Angeles'); note 'layoutTZ' is a string with two possible values "true" or "false". 'fromTZ' is only used if 'datetime'/'layout' don't contain TZ info; if not specified, the parser will keep the original TZ (or lack of it) of 'datetime'. 'toTZ' decides what TZ the output RFC3339 date time will be in.
func DateTimeToEpoch ¶
func DateTimeToEpoch(_ *transformctx.Ctx, datetime, fromTZ, unit string) (string, error)
DateTimeToEpoch parses a 'datetime' string intelligently, and returns its epoch number. 'fromTZ' is only used if 'datetime' doesn't contain TZ info; if not specified, the parser will keep the original TZ (or lack of it) of 'datetime'. 'unit' determines the time unit resolution of the output epoch number.
func DateTimeToRFC3339 ¶
func DateTimeToRFC3339(_ *transformctx.Ctx, datetime, fromTZ, toTZ string) (string, error)
DateTimeToRFC3339 parses a 'datetime' string intelligently, normalizes and returns it in RFC3339 format. 'fromTZ' is only used if 'datetime' doesn't contain TZ info; if not specified, the parser will keep the original TZ (or lack of it) of 'datetime'. 'toTZ' decides what TZ the output RFC3339 date time will be in.
func EpochToDateTimeRFC3339 ¶
EpochToDateTimeRFC3339 translates the 'epoch' timestamp under the given 'unit' into an RFC3339 formatted datetime string in the given timezone 'tz', if specified.
func Lower ¶
func Lower(_ *transformctx.Ctx, s string) (string, error)
Lower lowers the case of an input string.
func Now ¶
func Now(_ *transformctx.Ctx) (string, error)
Now returns the current time in UTC in RFC3339 format.
Types ¶
type CustomFuncType ¶
type CustomFuncType = interface{}
CustomFuncType is the type of a custom function. Has to use interface{} given we support non-variadic and variadic functions.
type CustomFuncs ¶
type CustomFuncs = map[string]CustomFuncType
CustomFuncs is a map from custom func names to an actual custom func.
func Merge ¶
func Merge(funcs ...CustomFuncs) CustomFuncs
Merge merges multiple custom func maps into one.