Skip to main content
Version: 0.2

Core functions

Below you can find custom core functions which are divided into categories based on the transformation purpose.

PostgreSQL driver functions​

FunctionDescription
nullReturns the NULL value that can be used for the driver encoding-decoding operations
isNullReturns true if the checked value is NULL
isNotNullReturns true if the checked value is not NULL
sqlCoalesceWorks as a standard SQL coalesce function. It allows you to choose the first non-NULL argument from the list.

JSON output function​

FunctionDescription
jsonExistsChecks if the path value exists in JSON. Returns true if the path exists.
mustJsonGetGets the JSON attribute value by path and throws an error if the path does not exist
mustJsonGetRawGets the JSON attribute raw value by path and throws an error if the path does not exist
jsonGetGets the JSON attribute value by path and returns nil if the path does not exist
jsonGetRawGets the JSON attribute raw value by path and returns nil if the path does not exist
jsonSetSets the value for the JSON document by path
jsonSetRawSets the raw value for the JSON document by path
jsonDeleteDeletes an attribute from the JSON document by path
jsonValidateValidates the JSON document syntax and throws an error if there are any issues
jsonIsValidChecks the JSON document for validity and returns true if it is valid
toJsonRawValueCasts any type of value to the raw JSON value

Testing functions​

FunctionDescription
isIntChecks if the value of an integer type
isFloatChecks if the value of a float type
isNilChecks if the value is nil
isStringChecks if the value of a string type
isMapChecks if the value of a map type
isSliceChecks if the value of a slice type
isBoolChecks if the value of a boolean type

Transformation and generators​

masking​

Replaces characters with asterisk * symbols depending on the provided masking rule. If the value is NULL, it is kept unchanged. This function is based on ggwhite/go-masker.

RuleDescriptionExample inputExample output
defaultReturns the sequence of * symbols of the same lengthtest1234********
nameMasks the second and the third lettersABCDA**D
passwordAlways returns a sequence of *
addressKeeps first 6 letters, masks the restLarnaca, makarios stLarnac*************
emailKeeps a domain and the first 3 letters, masks the restggw.chang@gmail.comggw****@gmail.com
mobileMasks 3 digits starting from the 4th digit09876543210987***321
telephoneRemoves (, ), , - symbols, masks last 4 digits of a telephone number, and formats it to (??)????-????0227993078(02)2799-****
idMasks last 4 digits of an IDA123456789A12345****
credit_cardMasks 6 digits starting from the 7th digit1234567890123456123456******3456
urlMasks the password part of the URL (if applicable)http://admin:mysecretpassword@localhost:1234/urihttp://admin:xxxxx@localhost:1234/uri
postcodeKeeps first 2 characters, masks the restSW1A 1AASW******

truncateDate​

Truncates datetime up to the provided part.

truncateDate(part string, original time.Time) (res time.Time, err error)

noiseDatePgInterval​

Adds or subtracts a random duration in the provided interval to or from the original date value.

noiseDate(interval string, original time.Time) (res time.Time, err error)

noiseFloat​

Adds or subtracts a random fraction to or from the original float value. Multiplies the original float value by a provided random value that is not higher than the ratio parameter and adds it to the original value with the option to specify the decimal via the decimal parameter.

noiseFloat(ratio float, decimal int, value float) (res float64, err error)

noiseInt​

Adds or subtracts a random fraction to or from the original integer value. Multiplies the original integer value by a provided random value that is not higher than the ratio parameter and adds it to the original value.

noiseInt(ratio float, value float) (res int, err error)

randomBool​

Generates a random boolean value.

randomDate​

Generates a random date within the provided interval.

randomDate(min time.Time, max time.Time) (res time.Time, err error)

randomFloat​

Generates a random float value within the provided interval.

randomFloat(min any, max any, decimal int) (res float, err error)

randomInt​

Generates a random integer value within the provided interval.

randomInt(min int, max int) (res int, err error)

randomString​

Generates a random string using the provided characters within the specified length range.

randomString(minLength int, maxLength int, symbols string) (res string, err error)

roundFloat​

Rounds a float value up to provided decimal.

roundFloat(decimal int, original float) (res float, err error)

tsModify​

Modify original time value by adding or subtracting the provided interval. The interval is a string in the format of the PostgreSQL interval.

tsModify(interval string, val time.Time) (time.Time, error)

Tools and expertise for reproducible, production-like environments.
Copyright © 2026 Greenmask, Inc.
Privacy Policy