utils

package
v1.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2020 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorMarshal

func ColorMarshal(jsonObj interface{}) ([]byte, error)

ColorMarshal marshals JSON data with default options

func Must

func Must(bytes []byte, err error) []byte

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.

func Retry

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.

Types

type ColorFormatter

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

func NewColorFormatter() *ColorFormatter

NewColorFormatter ...

func (*ColorFormatter) ColorMarshal

func (f *ColorFormatter) ColorMarshal(jsonObj interface{}) ([]byte, error)

ColorMarshal ...

type RetryCallback

type RetryCallback func(interface{}) bool

RetryCallback ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL