helpers

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 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,

	"toYaml":      toYaml,
	"indentBlock": indentBlock,
}

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 ConvertJSONArrayToYAML added in v0.2.5

func ConvertJSONArrayToYAML(jsonContent string) (string, error)

func ConvertJSONMapToYAML added in v0.2.5

func ConvertJSONMapToYAML(jsonContent string) (string, error)

func ConvertYAMLArrayToJSON added in v0.2.5

func ConvertYAMLArrayToJSON(yamlContent string) (string, error)

func ConvertYAMLMapToJSON added in v0.2.5

func ConvertYAMLMapToJSON(yamlContent string) (string, error)

func CreateTemplate added in v0.2.5

func CreateTemplate(name string) *template.Template

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 RenderTemplate added in v0.2.5

func RenderTemplate(tmpl *template.Template, data interface{}) (string, error)

func RenderTemplateFile added in v0.2.5

func RenderTemplateFile(filename string, data interface{}) (string, 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