Documentation
¶
Index ¶
- Variables
- func Colored(color string, a ...any) string
- func Contains[T comparable](slice []T, item T) bool
- func DurationRoundBy(duration time.Duration, n int64) time.Duration
- func Flatten[T any](nested [][]*T) []*T
- func NumLen[T Number](n T) T
- func PrettyJSONMarshal(v interface{}, maxItems int, prefix, indent string) []byte
- func PrintAndExit(message string)
- func PrintErr(err error)
- func PrintErrAndExit(err error)
- func PrintfC(color string, format string, a ...any)
- func PrintlnC(color string, a ...any)
- func RandomValueCycle[Value any](values []Value, localRand *rand.Rand) func() Value
- type Number
- type TruncatedMarshaller
Constants ¶
This section is empty.
Variables ¶
View Source
var Colors = struct { reset string Red string Green string Yellow string Orange string Blue string Magenta string Cyan string Gray string White string }{ Red: "\033[31m", Green: "\033[32m", Yellow: "\033[33m", Orange: "\033[38;5;208m", Blue: "\033[34m", Magenta: "\033[35m", Cyan: "\033[36m", Gray: "\033[37m", White: "\033[97m", // contains filtered or unexported fields }
Functions ¶
func Contains ¶
func Contains[T comparable](slice []T, item T) bool
func DurationRoundBy ¶ added in v0.5.5
func PrettyJSONMarshal ¶ added in v0.5.5
func PrintAndExit ¶
func PrintAndExit(message string)
func PrintErrAndExit ¶
func PrintErrAndExit(err error)
func RandomValueCycle ¶ added in v0.5.0
RandomValueCycle returns a function that cycles through the provided slice of values in a random order. Each call to the returned function will yield a value from the slice. The order of values is determined by the provided random number generator.
The returned function will cycle through the values in a random order until all values have been returned at least once. After all values have been returned, the function will reset and start cycling through the values in a random order again. The returned function isn't thread-safe and should be used in a single-threaded context.
Types ¶
type TruncatedMarshaller ¶ added in v0.5.5
type TruncatedMarshaller struct { Value interface{} MaxItems int }
func (TruncatedMarshaller) MarshalJSON ¶ added in v0.5.5
func (t TruncatedMarshaller) MarshalJSON() ([]byte, error)
Click to show internal directories.
Click to hide internal directories.