helpers

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TemplateFuncs = template.FuncMap{

	"trim":                    strings.TrimSpace,
	"trimRightSpace":          trimRightSpace,
	"trimTrailingWhitespaces": trimRightSpace,
	"rpad":                    rpad,
	"quote":                   quote,
	"stripNewlines":           stripNewlines,
	"quoteNewlines":           quoteNewlines,

	"toUpper": strings.ToUpper,
	"toLower": strings.ToLower,

	"replace":       replace,
	"replaceRegexp": replaceRegexp,

	"add": add,
	"sub": sub,
	"div": div,
	"mul": mul,

	"parseFloat": parseFloat,
	"parseInt":   parseInt,

	"currency": currency,

	"padLeft":  padLeft,
	"padRight": padRight,

	"bold":          bold,
	"underline":     underline,
	"italic":        italic,
	"strikethrough": strikethrough,
	"code":          code,
	"codeBlock":     codeBlock,
}

TemplateFuncs provides helpers for the standard cobra usage and help templates

Functions

func CancelOnSignal

func CancelOnSignal(ctx context.Context, signal_ os.Signal, cancel func()) error

func InterfaceListToStringList

func InterfaceListToStringList(list []interface{}) []string

func InterfaceToStringList

func InterfaceToStringList(list interface{}) []string

func LoadJSONFile

func LoadJSONFile(path string, target interface{}) error

func LoadYAMLFile

func LoadYAMLFile(path string, target interface{}) error

func RenderTemplateString

func RenderTemplateString(tmpl string, data interface{}) (string, error)

func StringInSlice

func StringInSlice(needle string, haystack []string) bool

func StructToMap

func StructToMap(i interface{}, lowerCaseKeys bool) map[string]interface{}

Types

This section is empty.

Jump to

Keyboard shortcuts

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