# README
Utils module
This repository contains code for common utils used in FOXDEN/CHESS services. It defines generic functions for Lists, Sets, etc.
# Functions
BasePath function provides end-point path for given api string.
CamelCaseToSnakeCase converts CamelCase string object to `camel_case`, code generated by ChatGPT, but further adjusted to accommodate special cases, like CESRConditions => cesr_conditions.
CastFloat function to check and cast interface{} to int64 data-type.
CastInt function to check and cast interface{} to int data-type.
CastInt64 function to check and cast interface{} to int64 data-type.
CastString function to check and cast interface{} to string data-type.
CheckEntries helper function to check that entries from list1 are all appear in list2.
Color prints given string in color based on ANSI escape codes, see http://www.wikiwand.com/en/ANSI_escape_code#/Colors.
ColorURL returns colored string of given url.
ConvertCacmeCaseKeys converts map with CamelCase keys to map with snake case keys.
ConvertFloat converts string representation of float scientific number to string int.
No description provided by the author
DIDKeys provide sorted, lower-case list of did keys from comma separated list of attributes.
Domain return domain string.
Equal tells whether a and b contain the same elements.
EqualLists helper function to compare list of strings.
Error prints Server error message with given arguments.
ErrPropagate helper function which can be used in defer ErrPropagate().
ErrPropagate2Channel helper function which can be used in goroutines as ch := make(chan interface{})
go func() { defer ErrPropagate2Channel(api, ch) someFunction() }().
Expire helper function to convert expire timestamp (int) into seconds since epoch.
FetchResponse fetches data for provided URL, args is a json dump of arguments.
helper function to extract file name.
FindFiles find files in given path.
FindInList helper function to find item in a list.
FullPath returns full path of given file name wrt to current location.
GetDid constructs did from given record.
GetEnv fetches value from user environement.
GetHash generates SHA256 hash for given data blob.
GoDeferFunc runs any given function in defered go routine.
HttpClient provides cert/token aware HTTP client.
HttpGet performs HTTP GET request with bearer token.
HttpPost performs HTTP POST request with bearer token.
HttpPostForm performs HTTP POST form request with bearer token.
InList helper function to check item in a list.
Insert inserts value into array at zero position.
IpAddresses returns list of IP addresses of the host.
IsFloat helper function to test if given value is a float.
IsInt helper function to test if given value is integer.
List2Set helper function to convert input list into set.
ListFiles lists files in a given directory.
MacAddr returns list of MAC addresses of the host.
MapIntKeys returns int keys from a map.
MapKeys returns string keys from a map.
Max helper function to perform Max operation over provided array of values.
Min helper function to perform Min operation over provided array of values.
NewTrustedClient provides pointer to trusted client initialized with appropriate fields.
OrderedSet implementa ordered set.
PaddedKey returns padded key up to maxLen.
PrintSQL prints SQL/args.
RandomString generates random string.
ReadToken function to either read file content or return given string.
RecordSize returns actual record size of given interface object.
ReplaceBinds replaces given pattern in string.
Response represents final response in a form of JSON structure we use custorm representation.
Set converts input list into set.
SizeFormat helper function to convert size into human readable form.
Stack returns full runtime stack.
Sum helper function to perform sum operation over provided array of values.
TimeFormat helper function to convert Unix time into human readable form.
UniqueFormValues returns unique list of values from http.Request.FormValue.
Unix2Time helper function to convert given time into Unix timestamp.
UnixTime helper function to convert given time into Unix timestamp.
UpdateOrderedDict returns new ordered list from given ordered dicts.
Warning prints Server error message with given arguments.
# Variables
PatternDataset represents CHESS dataset.
PatternFile represents CHESS file.
PatternFloat represents an integer pattern.
PatternInt represents an integer pattern.
PatternRun represents CHESS run.
PatternURL represents URL pattern.
TIMEOUT defines timeout for net/url request.
UrlCounter for profile output.
Verbose controls verbosity level of function printouts.
VERBOSE defines verbosity level.
# Structs
GzipReader struct to handle GZip'ed content of HTTP requests.
GzipWriter provides the same functionality as http.ResponseWriter It compresses data using compress/zip writer and provides headers from given http.ResponseWriter.
MacAddressRecord represents mac address record with interface name and address.
ResponseType structure is what we expect to get for our URL call.
TrustedClient represents trusted client.
# Interfaces
ListEntry identifies types used by list's generics function.
# Type aliases
DevNullWriter provides the same functionality as http.ResponseWriter to cover unit tests of DBS APIs.
Int64List implement sort for []int type.
IntList implement sort for []int type.
StdoutWriter provides the same functionality as http.ResponseWriter to cover unit tests of DBS APIs.
StringList implement sort for []string type.