Documentation
¶
Index ¶
- func ByteArrayToFloat(barray []byte) float64
- func ByteArrayToInt(bytes []byte) int
- func ByteArrayToUint(barray []byte) uint64
- func ByteArrayToUint8(barray []byte) uint8
- func Capitalize(sentence string) string
- func ColorMarshal(jsonObj interface{}) ([]byte, error)
- func ContainString(slice []string, value string) bool
- func EuclideanDivision(numerator, denominator int) (quotient, remainder int, err error)
- func FindClosest(arr []*big.Int, target *big.Int) (*big.Int, bool)
- func Flatten(arrayOfByteArray [][]byte) (concat []byte)
- func FloatToByteArray(data float64) (barray []byte)
- func FromHex(input string) ([]byte, error)
- func IntToByteArray(data int) []byte
- func IsPointer(item interface{}) bool
- func IsValue(item interface{}) bool
- func Must(bytes []byte, err error) []byte
- func PrettyPrintByte(b []byte) ([]byte, error)
- func PrettyPrintJSON(input interface{}) ([]byte, error)
- func Retry(numberOfRetry int, duration int, callback RetryCallback, args interface{}, ...)
- func ToHex(input []byte) string
- func Uint8ToByteArray(data uint8) (barray []byte)
- func UintToByteArray(data uint64) (barray []byte)
- type ColorFormatter
- type DivisionByZeroError
- type RetryCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteArrayToFloat ¶ added in v1.1.3
ByteArrayToFloat converts the passed byte array to a float64.
func ByteArrayToInt ¶
ByteArrayToInt converts the passed byte array to a int.
func ByteArrayToUint ¶
ByteArrayToUint converts the passed byte array into a uint64.
func ByteArrayToUint8 ¶
ByteArrayToUint8 converts the passed byte array into a uint8.
func Capitalize ¶ added in v1.3.4
Capitalize add an upper case at the beginning of the sentence
func ColorMarshal ¶ added in v1.3.9
ColorMarshal marshals JSON data with default options
func ContainString ¶
ContainString returns true if the passed slice of strings contains the passed string value
func EuclideanDivision ¶
EuclideanDivision returns the integer tuple (quotient, remainder) from the division of the past integers
func FindClosest ¶
FindClosest returns the closest number to the target in the passed array of numbers see https://www.geeksforgeeks.org/find-closest-number-array/
func FloatToByteArray ¶ added in v1.1.3
FloatToByteArray converts the passed float64 into a byte array.
func FromHex ¶
FromHex tries to convert an hexadecimal representation of a value to its corresponding byte array
func IntToByteArray ¶
IntToByteArray converts the passed integer to a byte array.
func IsPointer ¶
func IsPointer(item interface{}) bool
IsPointer returns `true` if the passed item is a pointer, not a value
func IsValue ¶
func IsValue(item interface{}) bool
IsValue returns `true` if the passed item is a value, not a pointer
func Must ¶
Must only returns the byte array from the argument tuple (byte array, error).
Use with caution, ie. only when you are absolutely certain that it shouldn't lead to a panic, or that if it leads to a panic it means that there's no way the program should work anyway. For example, `bytes := utils.Must(hex.DecodeString(h))` where `h` is an hexadecimal string hash for sure.
func Retry ¶ added in v1.3.9
func Retry(numberOfRetry int, duration int, callback RetryCallback, args interface{}, needToExit bool, then RetryCallback, thenArgs interface{})
Retry is a function supposed to be called in a goroutine to execute a callback a number of time with a given time between each repetition. duration is in Millisecond.
func Uint8ToByteArray ¶
Uint8ToByteArray converts the passed uint8 into a byte array.
func UintToByteArray ¶
UintToByteArray converts the passed integer into a byte array.
Types ¶
type ColorFormatter ¶ added in v1.3.9
type ColorFormatter struct { KeyColor *color.Color StringColor *color.Color BoolColor *color.Color NumberColor *color.Color NullColor *color.Color StringMaxLength int Indent int DisabledColor bool RawStrings bool }
ColorFormatter ...
func NewColorFormatter ¶ added in v1.3.9
func NewColorFormatter() *ColorFormatter
NewColorFormatter ...
func (*ColorFormatter) ColorMarshal ¶ added in v1.3.9
func (f *ColorFormatter) ColorMarshal(jsonObj interface{}) ([]byte, error)
ColorMarshal ...
type DivisionByZeroError ¶ added in v1.1.2
type DivisionByZeroError struct {
// contains filtered or unexported fields
}
DivisionByZeroError ...
func NewDivisionByZeroError ¶ added in v1.1.2
func NewDivisionByZeroError() *DivisionByZeroError
func (DivisionByZeroError) Error ¶ added in v1.1.2
func (e DivisionByZeroError) Error() string