util

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package util provides very generic helpers used across codebase.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorizeDiff added in v0.3.1

func ColorizeDiff(diff string) string

ColorizeDiff takes diff-formatter output and adds console colors to it.

func Indent

func Indent(text, indent string) string

Indent indents a block of text with an indent string.

func JoinSorted

func JoinSorted(values map[string]string, valueSeparator, keySeparator string) string

JoinSorted takes map of keys and values, sorts them by keys and joins with given separators.

func KeysStringMap

func KeysStringMap(m map[string]string) []string

KeysStringMap returns keys from given map.

func PickInt

func PickInt(values ...int) int

PickInt returns first non-zero integer passed.

func PickString

func PickString(values ...string) string

PickString returns first non-empty string passed.

func PickStringMap

func PickStringMap(values ...map[string]string) map[string]string

PickStringMap returns first non-empty map of strings.

func PickStringSlice

func PickStringSlice(values ...[]string) []string

PickStringSlice returns first non-empty strings slice.

Types

type ValidateErrors added in v0.7.0

type ValidateErrors []error

ValidateErrors is a collection of errors, which can be used when performing validation of structs to collect all possible errors and return them in one batch.

func (ValidateErrors) Error added in v0.7.0

func (e ValidateErrors) Error() string

func (ValidateErrors) Return added in v0.7.0

func (e ValidateErrors) Return() error

Return returns nil, if no errors has been added.

Jump to

Keyboard shortcuts

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