Documentation ¶
Overview ¶
Package utils implements helper functions
Index ¶
- Constants
- Variables
- func Capture(err error, _panic bool) sentry.EventID
- func CaptureWithContext(c context.Context, err error, _panic bool) sentry.EventID
- func CloseAnythingSafely(toClose interface{})
- func CloseSafely(closeable io.Closer)
- func Concat(slice ...interface{}) string
- func ConvertInterfaceToString(val interface{}) (string, bool)
- func Distinct(slice []string) []string
- func DownloadFile(ctx context.Context, url, filepath string) (err error)
- func Evaluate(templateText string, metadata map[string]interface{}) string
- func EvaluateAugmentedFuncMap(templateText string, metadata map[string]interface{}, ...) string
- func EvaluateAugmentedFuncMapSafely(templateText string, metadata map[string]interface{}, ...) (string, error)
- func FlattenStringSlice(nestedList []interface{}) (slice []string)
- func GetEnv(key, fallback string) string
- func GetFile(fileURLPath, toFile string) (err error)
- func HTTPGet(url string) (payloadBytes []byte, err error)
- func HTTPGetWithCACrt(pathToCaCertFile string, url string) (payloadBytes []byte, err error)
- func IntInSlice(a int, list []int) bool
- func IsDeepEqual(x, y interface{}) bool
- func IsEqual(x, y interface{}) bool
- func IsStringSliceEqual(a, b []string, option int) bool
- func IsZeroOfUnderlyingType(x interface{}) bool
- func Join(slice []string, delimiter string) string
- func JoinInt(delimiter string, slice []int) string
- func MD5(str string) string
- func ReadCsvFile(filePath string) ([][]string, error)
- func ReadYamlFile(filePath string, out interface{}) (err error)
- func Reverse(s string) string
- func SliceInSlice(a []string, list []string) bool
- func StringInSlice(a string, list []string) bool
- func StringListify(slice []string, delimiter, finalDelimiter string) string
- func StringToTimestamp(unixTimestamp string) (time.Time, error)
- func StringifyToJson(i interface{}) (stringifiedJson string)
- func TimeTrack(start time.Time)
- func ToCamelCase(str string) string
- func ToString(toConvert interface{}) string
- func TrimSuffix(s, suffix string) string
- func WriteToFile(stream []byte, toFile string) (file *os.File, err error)
Constants ¶
const ( IgnoreRepeats = iota IgnoreOrdering ConsiderOrdering )
Variables ¶
var DevMode = strings.ToUpper(os.Getenv("ENVIRONMENT")) == "DEV"
Functions ¶
func CaptureWithContext ¶
Handles an error by capturing it on Sentry and logging the same on STDOUT
func CloseAnythingSafely ¶
func CloseAnythingSafely(toClose interface{})
Closes an interface which implements io.Closer safely
func CloseSafely ¶
Closes a struct which implements io.Closer safely
func ConvertInterfaceToString ¶
ConvertInterfaceToString takes an interface as input and tries to assert it as a string if not nil. It returns the string value after the said assertion. False is returned if assertion fails
func DownloadFile ¶
DownloadFile - Download from url to a local file
func FlattenStringSlice ¶
func FlattenStringSlice(nestedList []interface{}) (slice []string)
flattens a slice of []interface{} to a []string. The flattening is done only for one level of nesting currently
func GetFile ¶
GetFile - Download file from URL, create directories/file and write to it TODO: Allow cancelable requests using contexts https://github.com/hashicorp/go-getter/issues/102
func HTTPGetWithCACrt ¶
HTTPGetWithCACrt - Download from url to a bytes array using CA crt pathToCaCertFile = Mount path of the CAcrt file
func IntInSlice ¶
StringInSlice - Returns True when two strings have one element in common, False otherwise
func IsDeepEqual ¶
func IsDeepEqual(x, y interface{}) bool
IsDeepEqual - Returns True when the two passed values are same, else False
func IsEqual ¶
func IsEqual(x, y interface{}) bool
IsEqual - Returns True when the two passed values are same, else False
func IsStringSliceEqual ¶
Checks if a string slice is equal or not.
func IsZeroOfUnderlyingType ¶
func IsZeroOfUnderlyingType(x interface{}) bool
IsZeroOfUnderlyingType - Returns True when the passed value is zero
func ReadCsvFile ¶
ReadCsvFile - Read from csv file and return results as [][]string
func ReadYamlFile ¶
ReadYamlFile - Read from YAML file and return results
func SliceInSlice ¶
SliceInSlice - Returns True when two []string have one element in common, False otherwise
func StringInSlice ¶
StringInSlice - Returns True when two strings have one element in common, False otherwise
func StringListify ¶
Concatenates a slice of strings with the delimiter in question Uses the final delimiter to concatenate the final string in the slice
func StringToTimestamp ¶
StringToTimestamp - Converts a unix timestamp string to unix timestamp format
func StringifyToJson ¶
func StringifyToJson(i interface{}) (stringifiedJson string)
func TimeTrack ¶
Prints the time taken to run a function. Should be used to measure performance. Usage: Add "defer TimeTrack(time.Now())" as a statement at the beginning of any function
func ToCamelCase ¶
Types ¶
This section is empty.