util

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2020 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyMap added in v0.7.0

func CopyMap(m map[string]interface{}) map[string]interface{}

CopyMap creates a deep copy of map.

func CopySlice added in v0.7.0

func CopySlice(s []interface{}) []interface{}

CopySlice creates a deep copy of a slice.

func FuncMap

func FuncMap(t *template.Template) template.FuncMap

FuncMap exports a set of functions in template.FuncMap format: - tmpl: execute a sub-template by name. Sub-templates are chosen from t namespace - tmplExec: execute a template text - tmplFile: execute a template stored in a file

func HasMajorChanges added in v0.7.0

func HasMajorChanges(l, r map[string]interface{}) bool

HasMajorChanges is true if differences between l and r are deemed as significant. Importance of differences is measured field-by-field using a LCS-like distance. It is enough for one field to get less than 80% of similar runes to result in a true answer. Any field from l lacking in r or present in r but lacking in l is not seen as a significant change.

func IsNotZero added in v0.7.0

func IsNotZero(v interface{}) bool

IsNotZero checks whether the provided interface is not the zero value.

func IsZero

func IsZero(v interface{}) bool

IsZero checks whether the provided interface is the zero value.

func ParseTime

func ParseTime(text string) (t time.Time, err error)

ParseTime parses a time stamp, trying different time format.

func Sort added in v0.5.0

func Sort(maps []map[string]interface{}, sortBy []string) []map[string]interface{}

Sort sorts collection of map[string]interface{} according to the provided sort order.

Types

type MultiErrors

type MultiErrors []error

MultiErrors represents a collection of errors.

func (*MultiErrors) Add

func (c *MultiErrors) Add(err error)

Add adds a new error to the errors collection.

func (*MultiErrors) Addf added in v0.7.0

func (c *MultiErrors) Addf(format string, a ...interface{})

Addf adds a new error to errors collection using fmt.Errorf format.

func (*MultiErrors) Err

func (c *MultiErrors) Err() error

Err returns nil if the errors collection is empty or nil, it returns itself otherwise.

func (*MultiErrors) Error

func (c *MultiErrors) Error() (s string)

Error concatenates all errors in the collection. It allows to satisfy error interface.

Jump to

Keyboard shortcuts

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