customfuncs
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
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 suitablefor all versions of schemas.
Functions¶
funcCoalesce¶
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 orall of them are empty, then an empty string is returned. Note: a blank string (with only whitespaces)is not considered as empty.
funcConcat¶
func Concat(_ *transformctx.Ctx, strs ...string) (string,error)
Concat concatenates a number of strings together. If no strings specified, "" is returned.
funcDateTimeLayoutToRFC3339¶
func DateTimeLayoutToRFC3339(_ *transformctx.Ctx, datetime, layout, layoutTZ, fromTZ, toTZstring) (string,error)
DateTimeLayoutToRFC3339 parses a 'datetime' string according a given 'layout' and normalizes and returns itin RFC3339 format. 'layoutTZ' specifies whether the 'layout' contains timezone info (such as tz offset, tzshort names lik 'PST', or standard IANA tz long name, such as 'America/Los_Angeles'); note 'layoutTZ' is astring with two possible values "true" or "false". 'fromTZ' is only used if 'datetime'/'layout' don't containTZ info; if not specified, the parser will keep the original TZ (or lack of it) of 'datetime'. 'toTZ' decideswhat TZ the output RFC3339 date time will be in.
funcDateTimeToEpoch¶
func DateTimeToEpoch(_ *transformctx.Ctx, datetime, fromTZ, unitstring) (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 theoriginal TZ (or lack of it) of 'datetime'. 'unit' determines the time unit resolution of theoutput epoch number.
funcDateTimeToRFC3339¶
func DateTimeToRFC3339(_ *transformctx.Ctx, datetime, fromTZ, toTZstring) (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 theoriginal TZ (or lack of it) of 'datetime'. 'toTZ' decides what TZ the output RFC3339 date time will be in.
funcEpochToDateTimeRFC3339¶
EpochToDateTimeRFC3339 translates the 'epoch' timestamp under the given 'unit' into an RFC3339 formatteddatetime string in the given timezone 'tz', if specified.
funcLower¶
func Lower(_ *transformctx.Ctx, sstring) (string,error)
Lower lowers the case of an input string.
funcNow¶
func Now(_ *transformctx.Ctx) (string,error)
Now returns the current time in UTC in RFC3339 format.
Types¶
typeCustomFuncType¶
type CustomFuncType = interface{}
CustomFuncType is the type of custom function. Has to use interface{} given we supportnon-variadic and variadic functions.
typeCustomFuncs¶
type CustomFuncs = map[string]CustomFuncType
CustomFuncs is a map from custom func names to an actual custom func.
funcMerge¶
func Merge(funcs ...CustomFuncs)CustomFuncs
Merge merges multiple custom func maps into one.