Documentation ¶
Index ¶
- func BytesToString(b []byte) string
- func CheckForError(err error, msg ...string) (toReturn string)
- func ConvertReplyType[T any](desiredType T, reply []byte) T
- func ExistsInSlice(slice interface{}, value interface{}) bool
- func FlattenMap(nested map[string]interface{}, opts *FlattenOptions) (m map[string]interface{}, err error)
- func IsZero(v interface{}) bool
- func RemoveFromSlice(slice interface{}, value interface{})
- func RemoveFromSliceByIndex(slice interface{}, index int)
- func StringToBytes(s string) []byte
- func Trace() string
- func UnflattenMap(flat map[string]interface{}, opts *FlattenOptions) (nested map[string]interface{}, err error)
- func UniqueSlice(slice interface{}) interface{}
- type CompareStructReplacedResult
- type FlattenOptions
- type LogConfig
- func (l *LogConfig) Critical(message string, v ...map[string]interface{})
- func (l *LogConfig) Debug(message string, v ...map[string]interface{})
- func (l *LogConfig) Error(message string, v ...map[string]interface{})
- func (l *LogConfig) Info(message string, v ...map[string]interface{})
- func (l *LogConfig) Warning(message string, v ...map[string]interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶ added in v0.0.20
BytesToString converts a byte slice to a string without copying the underlying data.
func CheckForError ¶
CheckForError takes err and additional message as parameter, Returning pre-formatted error message with stack trace if err is not nil
func ConvertReplyType ¶ added in v0.0.22
Convert any []byte reply to the desired reply type Useful for converting json into structs.
func ExistsInSlice ¶
func ExistsInSlice(slice interface{}, value interface{}) bool
ExistsInSlice returns true if the given value exists in the given slice.
func FlattenMap ¶ added in v0.0.9
func FlattenMap(nested map[string]interface{}, opts *FlattenOptions) (m map[string]interface{}, err error)
Returns flat map from the provided nested map[string]interface{} For example:
nested := map[string]interface{}{ "a": map[string]interface{}{ "b": map[string]interface{}{ "c": "d", }, }, } flat := FlattenMap(nested) flat equals to map[string]interface{}{ "a.b.c": "d", }
func IsZero ¶
func IsZero(v interface{}) bool
IsZero reports whether v is zero struct Does not support cycle pointers for performance, so as json
func RemoveFromSlice ¶
func RemoveFromSlice(slice interface{}, value interface{})
RemoveFromSlice removes the given value from the given slice. The value is replaced with Zero value of the same type. For string it is an empty string. For integers it is 0.
func RemoveFromSliceByIndex ¶
func RemoveFromSliceByIndex(slice interface{}, index int)
RemoveFromSlice removes the given value from the given slice using provided index. The value is replaced with Zero value of the same type. For string it is an empty string. For integers it is 0.
func StringToBytes ¶ added in v0.0.20
StringToBytes converts a string to a byte slice without copying the underlying data.
func Trace ¶
func Trace() string
Trace returns trace information about executing function together line number and file name It's useful for debugging purposes
func UnflattenMap ¶ added in v0.0.9
func UnflattenMap(flat map[string]interface{}, opts *FlattenOptions) (nested map[string]interface{}, err error)
Unflatten the map, it returns a nested map of a map By default, the flatten has Separator equal to "."
Example:
flat := map[string]interface{}{ "a.b.c": "d", } nested := UnflattenMap(flat) nested equals to map[string]interface{}{ "a": map[string]interface{}{ "b": map[string]interface{}{ "c": "d", }, }, }
func UniqueSlice ¶ added in v0.0.12
func UniqueSlice(slice interface{}) interface{}
UniqueSlice returns slice with reordered and unique values. Please note that function does not modify the original slice but returns a new one.
Types ¶
type CompareStructReplacedResult ¶ added in v0.0.15
type CompareStructReplacedResult struct { Value interface{} OldValue interface{} Key string }
func CompareStructsReplaced ¶ added in v0.0.15
func CompareStructsReplaced(a, b interface{}) ([]CompareStructReplacedResult, bool, error)
CompareStructReplaced compares two structs after converting them into json and returns: - array of differences - bool true if there's no differences - error if such occurs