A Go module containing a number of helper functions that are used by Hornbill Go open source tools.
Calculates a new date/time when giving a starting point and a duration.
- time.Time: A starting date & time
- string: a duration string in the following format:
- For adding a period of time from the start time: P1D2H3M4S This will add 1 day (1D), 2 hours (2H), 3 minutes (3H) and 4 seconds (4S) to the provided time
- For subtracting a period of time from the start time: -P1D2H3M4S - This will subtract 1 day (1D), 2 hours (2H), 3 minutes (3H) and 4 seconds (4S) from the provided time
- time.Time: The calculated date & time
- int: The number of seconds between the starting and calculated date/times.
Takes a float64 value, returns a human readable storage capacity (kB, MB, GB, TB, PB) string.
- float64: Float to convert in to a capacity string
- string: Formatted storage capacity string
Create or append to a log file in to the /log folder of the folder where the Go code is executed.
- int: Log entry type:
- 1: [DEBUG] CLI output GREEN
- 2: [MESSAGE] CLI output GREEN
- 3: No type prefix, CLI output GREEN
- 4: [ERROR] CLI output RED
- 5: [WARNING] CLI output YELLOW
- 6: No type prefix, CLI output YELLOW
- string: Log entry string
- bool: Should the log entry also be output to the CLI
- string: Log file name
CLI prompt to user, expects a user response of:
- Fuzzy yes (y, Y, yes, Yes, YES) or input param provided string
- Fuzzy no (n, N, no, No, NO) Function does not return until an expected response is given.
- string: An overriding replacement for the fuzzy yes expected response
Uses the Windows Data Protection API to encrypt a string with a given entropy.
- string: The string you wish to encrypt
- string: The entropy
- string: The encrypted string
- error: Any error returned
Uses the Windows Data Protection API to decrypt a string with a given entropy.
- string: The string you wish to decrypt
- string: The entropy
- string: The decrypted string
- error: Any error returned