Documentation
¶
Index ¶
- Constants
- Variables
- 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 Chunk(slice []string, chunkSize int) [][]string
- func ColorMarshal(jsonObj interface{}) ([]byte, error)
- func ContainString(slice []string, value string) bool
- func DateFormat(t time.Time, layout string) string
- func DateLayoutJava2Go(layout string) string
- 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 Reverse(str string) string
- func ToHex(input []byte) string
- func ToUTF8(encoded, format string) (decoded string, err error)
- func Uint8ToByteArray(data uint8) (barray []byte)
- func UintToByteArray(data uint64) (barray []byte)
- type ColorFormatter
- type DivisionByZeroError
- type RetryCallback
Constants ¶
const (
ISO_8601 = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
)
Variables ¶
var ( ISO_8859_1 = charmap.ISO8859_1.String() // ISO 8859-1 ISO_8859_2 = charmap.ISO8859_2.String() // ISO 8859-2 ISO_8859_3 = charmap.ISO8859_3.String() // ISO 8859-3 ISO_8859_4 = charmap.ISO8859_4.String() // ISO 8859-4 MACINTOSH = charmap.Macintosh.String() // Macintosh UTF_8 = "utf-8" WINDOWS_1252 = charmap.Windows1252.String() // Windows 1252 )
Encoding formats
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 DateFormat ¶ added in v1.4.10
DateFormat formats the passed time to the Java-notated layout, eg. `yyyy-MM-dd`
func DateLayoutJava2Go ¶ added in v1.4.10
DateLayoutJava2Go transforms a Java notation to its Golang equivalent
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 ToUTF8 ¶ added in v1.4.3
ToUTF8 transforms a encoded string in the passed encoding format to a UTF-8 string
NB: For now, it only supports ISO 8859-1, ISO 8859-2, ISO 8859-3, ISO 8859-4, Macintosh and Windows 1252 formats
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