Documentation ¶
Overview ¶
Package commons is for utilities not related to business logic (files, debug, collections, etc)
Index ¶
- Variables
- func All(vs []string, f func(string) bool) bool
- func Any(vs []string, f func(string) bool) bool
- func Contains(vs []string, t string) bool
- func Debug(message string)
- func Debugf(message string, args ...interface{})
- func FillTemplate(templatePath, finalPath string, mapping map[string]string) error
- func Filter(vs []string, f func(string) bool) []string
- func Include(vs []string, t string) bool
- func Index(vs []string, t string) int
- func LazyDebug(getMsgFn MessageProvider)
- func MakeDir(path string) error
- func Map(vs []string, f func(string) string) []string
- func RemoveIndex(s []string, index int) []string
- func RemoveLast(s []string) []string
- func SortKeys(m map[string]interface{}) []string
- func SortMapKeys(m map[string]string) []string
- func WriteToJSONFile(content interface{}, fileName string) error
- type MessageProvider
Constants ¶
This section is empty.
Variables ¶
var ( // IsDebugEnabled is true when the DEBUG env var is not empty. IsDebugEnabled = os.Getenv("DEBUG") != "" )
Functions ¶
func Debugf ¶
func Debugf(message string, args ...interface{})
Debugf prints message when debug mode is enabled. Substitutes format with provided arguments. Works like fmt.Sprintf.
func FillTemplate ¶
FillTemplate fills source template from file and stores it under provided destination. To fill the template provided map with mappings is used.
func Filter ¶
Filter returns a new slice containing all strings in the slice that satisfy the predicate f.
func LazyDebug ¶
func LazyDebug(getMsgFn MessageProvider)
LazyDebug should be used when message construction is heavy and should be executed only when debug is enabled
func Map ¶
Map returns a new slice containing the results of applying the function f to each string in the original slice.
func RemoveIndex ¶
RemoveIndex removes the element from the slice by its index.
func RemoveLast ¶
RemoveLast removes the last element from the slice and returns the altered slice.
func SortMapKeys ¶
SortMapKeys sorts keys of the map of strings and returns them in the slice.
func WriteToJSONFile ¶ added in v1.1.0
WriteToJSONFile marshalls provided content to json and stores it in file with provided name.
Types ¶
type MessageProvider ¶
type MessageProvider func() string
MessageProvider allows for definition of MessageProvider that will be invoked in order to obtain the message before logging it.
Directories ¶
Path | Synopsis |
---|---|
Package cli is for common CLI utilities
|
Package cli is for common CLI utilities |
Package testassist holds testing helpers
|
Package testassist holds testing helpers |