Documentation
¶
Index ¶
- func CsvStringOfTokensToMap(log logger.Logger, s string) (map[string]string, error)
- func CsvToStringSliceTrimSpaces(s string) []string
- func CsvToStringSliceTrimSpaces2(s string) (retval []string)
- func CsvToStringSliceTrimSpacesRemoveQuotes(s string) []string
- func EscapeQuotesInString(s string) string
- func GenerateSliceOfColsEqualCols(colList []string, srcAlias string, tgtAlias string) []string
- func GenerateStringOfColsEqualsCols(colList []string, srcAlias string, tgtAlias string, separator string) string
- func GetDsnEnvVarName(connectionName string) string
- func GetEnvVar(k string, mandatory bool) (string, error)
- func GetRegionEnvVarName(connectionName string) string
- func GetStringFromInterface(log logger.Logger, input interface{}, useUTC bool) (retval string)
- func GetStringFromInterfacePreserveTimeZone(log logger.Logger, input interface{}) (retval string)
- func GetStringFromInterfaceUseUtcTime(log logger.Logger, input interface{}) (retval string)
- func GetStructErrorTxt4UnsetFields(i interface{}, errTags *[]string)
- func GetTrueFalseStringAsBool(s string) bool
- func InterfaceToString(src []interface{}) []string
- func OrderedMapToTokens(om *ordered_map.OrderedMap, trimQuotes bool) (string, error)
- func OrderedMapValuesToStringSlice(log logger.Logger, om *om.OrderedMap, l *[]string, idx *int)
- func ReadValueFromEnv(name string, val *string) error
- func ReadValueFromEnvWithDefault(name string, defaultValue string) (v string)
- func Split(s string, c string) (string, string)
- func SplitRight(s string, c string) (string, string)
- func StringSliceToOrderedMap(s []string) *om.OrderedMap
- func StringSliceToTokens(log logger.Logger, s []string) (retval string)
- func StringsToCsv(s []string) string
- func StringsToCsv2(log logger.Logger, s []string) string
- func ToUpperIfNotQuoted(s []string) []string
- func ToUpperQuotedIfNotQuoted(s []string) []string
- func TokensToOrderedMap(s string) *ordered_map.OrderedMap
- func ValidateStructIsPopulated(cfg interface{}) (err error)
- type AtomBool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CsvStringOfTokensToMap ¶
CsvStringOfTokensToMap expects a CSV of tokens "testA:testB, xyz1:abc2, ""j kh3: r st4"", ""j kh3:xyz"" and returns: m[testA]=testB m[xyz1]=abc2 m["j kh3"]=xyz It will take the last seen value for a given token.
func CsvToStringSliceTrimSpaces ¶
Convert a string of the form, 'f1,f2,f3...' into a slice of string values. 1) Split on comma. 2) Remove leading and trailing spaces.
func CsvToStringSliceTrimSpaces2 ¶
CsvToStringSliceTrimSpaces2 converts a string of the form, 'f1, f2, f3, ...' into a slice of string values.
func CsvToStringSliceTrimSpacesRemoveQuotes ¶
Convert a string of the form, '"f1","f2","f3"...' into a slice of string values. 1) Split on comma. 2) Remove leading and trailing spaces. TODO: use proper CSV library to unwrap fields.
func EscapeQuotesInString ¶
EscapeQuotesInString will escape any quotes found in the strings with "\".
func GenerateStringOfColsEqualsCols ¶
func GenerateStringOfColsEqualsCols(colList []string, srcAlias string, tgtAlias string, separator string) string
Function to get a string "src.col1 = tgt.col1, src.col2 = tgt.col2" using the colList supplier and where the comma can be whatever separator you pass in.
func GetDsnEnvVarName ¶
func GetEnvVar ¶
GetEnvVar fetches OS environment variable. If the variable is not set it returns empty string. It also returns an error if there is a missing value AND mandatory == true.
func GetRegionEnvVarName ¶
func GetStringFromInterface ¶
GetStringFromInterface will convert interface{} value to a string. Optionally return Times in UTC.
func GetStringFromInterfacePreserveTimeZone ¶
GetStringFromInterfacePreserveTimeZone will convert interface{} value to a string. Times will be in local time.
func GetStringFromInterfaceUseUtcTime ¶
GetStringFromInterfacePreserveTimeZone will convert interface{} value to a string for the purposes of gt/lt comparison. Times will be converted to UTC for string comparison! TODO: remove logging from basic helper funcs
func GetStructErrorTxt4UnsetFields ¶
func GetStructErrorTxt4UnsetFields(i interface{}, errTags *[]string)
getStructErrorTxt4UnsetFields will reflect over interface i and build a slice containing error text strings for any struct fields that are unset i.e. are the zero value for the given field type. The error text strings are fetched from the errorTxt tags values found in the supplied interface (struct) where tag mandatory:"yes" is set.
func GetTrueFalseStringAsBool ¶
GetTrueFalseStringAsBool trims spaces from s and checks if it can regexp (case insensitive) match "true". It returns true if there's a match else false.
func InterfaceToString ¶
func InterfaceToString(src []interface{}) []string
func OrderedMapToTokens ¶
func OrderedMapToTokens(om *ordered_map.OrderedMap, trimQuotes bool) (string, error)
OrderedMapToTokens converts the supplied ordered map to a CSV of key:value,key:value,... All keys and values are expected to be of type string.
func OrderedMapValuesToStringSlice ¶
Function to build a list of values found in ordered map 'om' supplied as input. Output - this function modifies the supplied list 'l' and 'idx' by reference.
func ReadValueFromEnv ¶
ReadValueFromEnv will convert name into an environment variable using EnvVarPrefix and the name converted to upper with dashes converted to underscores all separated by underscores. It will read the env var and populate the supplied val. If the env var is not set then return an error.
func ReadValueFromEnvWithDefault ¶
ReadValueFromEnvWithDefault will read the value of name from the environment into v. If it's not set then it will apply the supplied defaultValue and return v.
func StringSliceToOrderedMap ¶
func StringSliceToOrderedMap(s []string) *om.OrderedMap
StringSliceToOrderedMap adds each value in s to an ordered map with key and value set to the value in s.
func StringSliceToTokens ¶
SliceOfStringsToStringOfTokens converts slice { col1,col2 ,col3} to "col1:col1,col2:col2,col3:col3" Spaces are trimmed from the input.
func StringsToCsv ¶
StringsToCsv joins the strings by "," TODO: handle comma in a column name as this stuff is often turned into a CSV!
func ToUpperIfNotQuoted ¶
ToUpperIfNotQuoted converts any non-quoted strings to upper case.
func ToUpperQuotedIfNotQuoted ¶
ToUpperQuotedIfNotQuoted converts any non-quoted strings to upper case and quotes them.
func TokensToOrderedMap ¶
func TokensToOrderedMap(s string) *ordered_map.OrderedMap
Convert a string of the form, 'k1:v1,k2:v2' into an ordered map and return a pointer to it. 1) Split on comma to find each key:value pair. 2) Split on colon to separate the key from the value.
func ValidateStructIsPopulated ¶
func ValidateStructIsPopulated(cfg interface{}) (err error)
validateStructIsPopulated will check if any mandatory fields in cfg are missing. It uses struct tags to determine which fields are mandatory and the error text to fetch. The error text returned is just a list of the struct tags with key "errorTxt".