Documentation ¶
Index ¶
- Variables
- func CancelOnSignal(ctx context.Context, signal_ os.Signal, cancel func()) error
- func CastInterfaceListToFloatList[To FloatNumber](list []interface{}) ([]To, bool)
- func CastInterfaceListToIntList[To SignedInt | UnsignedInt](list []interface{}) ([]To, bool)
- func CastInterfaceToFloat[To FloatNumber](i interface{}) (To, bool)
- func CastInterfaceToFloatList[To FloatNumber](i interface{}) ([]To, bool)
- func CastInterfaceToInt[To SignedInt | UnsignedInt](i interface{}) (To, bool)
- func CastInterfaceToIntList[To SignedInt | UnsignedInt](i interface{}) ([]To, bool)
- func CastInterfaceToStringMap[To any, From any](m interface{}) (map[string]To, bool)
- func CastList[To any, From any](list []From) ([]To, bool)
- func CastList2[To any, From any](list interface{}) ([]To, bool)
- func CastMapMember[To any](m map[string]interface{}, k string) (*To, bool)
- func CastStringMap[To any, From any](m map[string]From) (map[string]To, bool)
- func CastToNumberList[To Number, From Number](list []From) ([]To, bool)
- func ConvertJSONArrayToYAML(jsonContent string) (string, error)
- func ConvertJSONMapToYAML(jsonContent string) (string, error)
- func ConvertYAMLArrayToJSON(yamlContent string) (string, error)
- func ConvertYAMLMapToJSON(yamlContent string) (string, error)
- func CreateHTMLTemplate(name string) *html.Template
- func CreateTemplate(name string) *template.Template
- func Float64SliceToStringSlice(list []float64) []string
- func IntSliceToStringSlice(list []int) []string
- func InterfaceListToStringList(list []interface{}) []string
- func InterfaceToStringList(list interface{}) []string
- func LoadJSONFile(path string, target interface{}) error
- func LoadYAMLFile(path string, target interface{}) error
- func ParseCSV(r io.Reader, options ...ParseCSVOption) ([]map[string]interface{}, error)
- func ParseFS(t *template.Template, f fs.FS, patterns ...string) error
- func ParseHTMLFS(t *html.Template, f fs.FS, pattern string, baseDir string) error
- func RenderHtmlTemplateString(tmpl string, data interface{}) (string, error)
- func RenderTemplate(tmpl TemplateExecute, data interface{}) (string, error)
- func RenderTemplateFile(filename string, data interface{}) (string, error)
- func RenderTemplateString(tmpl string, data interface{}) (string, error)
- func SetFloatListReflectValue[To Number](value reflect.Value, v interface{}) error
- func SetIntListReflectValue[To Number](value reflect.Value, v interface{}) error
- func SetReflectValue(value reflect.Value, v interface{}) error
- func StringInSlice(needle string, haystack []string) bool
- func StructToMap(i interface{}, lowerCaseKeys bool) map[string]interface{}
- func ToAlphaString(n int) string
- type FloatNumber
- type Number
- type ParseCSVOption
- type SignedInt
- type TemplateExecute
- type UnsignedInt
Constants ¶
This section is empty.
Variables ¶
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, "replaceRegexp": replaceRegexp, "add": add, "sub": sub, "div": div, "mul": mul, "parseFloat": parseFloat, "parseInt": parseInt, "currency": currency, "padLeft": padLeft, "padRight": padRight, "padCenter": padCenter, "bold": bold, "underline": underline, "italic": italic, "strikethrough": strikethrough, "code": code, "codeBlock": codeBlock, "toYaml": toYaml, "indentBlock": indentBlock, "styleBold": styleBold, }
TemplateFuncs provides helpers for the standard cobra usage and help templates
Functions ¶
func CancelOnSignal ¶
func CastInterfaceListToFloatList ¶ added in v0.2.13
func CastInterfaceListToFloatList[To FloatNumber](list []interface{}) ([]To, bool)
func CastInterfaceListToIntList ¶ added in v0.2.13
func CastInterfaceListToIntList[To SignedInt | UnsignedInt](list []interface{}) ([]To, bool)
func CastInterfaceToFloat ¶ added in v0.2.13
func CastInterfaceToFloat[To FloatNumber](i interface{}) (To, bool)
func CastInterfaceToFloatList ¶ added in v0.2.13
func CastInterfaceToFloatList[To FloatNumber](i interface{}) ([]To, bool)
func CastInterfaceToInt ¶ added in v0.2.13
func CastInterfaceToInt[To SignedInt | UnsignedInt](i interface{}) (To, bool)
func CastInterfaceToIntList ¶ added in v0.2.13
func CastInterfaceToIntList[To SignedInt | UnsignedInt](i interface{}) ([]To, bool)
func CastInterfaceToStringMap ¶ added in v0.2.13
func CastList ¶ added in v0.2.6
CastList casts a list of From objects to To, by casting it to an interface{} in between.
func CastList2 ¶ added in v0.2.6
CastList2 attempts even harder to cast a list of From object to To, by checking if we might be dealing with a list masquerading as a interface{}, then a []interface{}, before checking for []To.
func CastMapMember ¶ added in v0.2.6
func CastStringMap ¶ added in v0.2.6
func CastToNumberList ¶ added in v0.2.6
CastToNumberList casts a list of From objects to To. This is useful for transform between different int types, for example.
func ConvertJSONArrayToYAML ¶ added in v0.2.5
func ConvertJSONMapToYAML ¶ added in v0.2.5
func ConvertYAMLArrayToJSON ¶ added in v0.2.5
func ConvertYAMLMapToJSON ¶ added in v0.2.5
func CreateHTMLTemplate ¶ added in v0.2.16
func CreateTemplate ¶ added in v0.2.5
func Float64SliceToStringSlice ¶ added in v0.2.16
func IntSliceToStringSlice ¶ added in v0.2.16
func InterfaceListToStringList ¶
func InterfaceListToStringList(list []interface{}) []string
func InterfaceToStringList ¶
func InterfaceToStringList(list interface{}) []string
func LoadJSONFile ¶
func LoadYAMLFile ¶
func ParseCSV ¶ added in v0.2.8
func ParseCSV(r io.Reader, options ...ParseCSVOption) ( []map[string]interface{}, error, )
func ParseFS ¶ added in v0.2.16
ParseFS will recursively glob for all the files matching the given patterns, and load them into one big template (with sub-templates). The globs use bmatcuk/doublestar and support ** notation for recursive globbing.
func ParseHTMLFS ¶ added in v0.2.16
ParseHTMLFS will recursively glob for all the files matching the given patterns, and load them into one big template (with sub-templates). It is the html.Template equivalent of ParseFS.
The globs use bmatcuk/doublestar and support ** notation for recursive globbing.
func RenderHtmlTemplateString ¶ added in v0.2.7
func RenderTemplate ¶ added in v0.2.5
func RenderTemplate(tmpl TemplateExecute, data interface{}) (string, error)
func RenderTemplateFile ¶ added in v0.2.5
func RenderTemplateString ¶
func SetFloatListReflectValue ¶ added in v0.2.6
func SetIntListReflectValue ¶ added in v0.2.6
func SetReflectValue ¶ added in v0.2.6
func StringInSlice ¶
func StructToMap ¶
func ToAlphaString ¶ added in v0.2.43
Types ¶
type FloatNumber ¶ added in v0.2.6
type ParseCSVOption ¶ added in v0.2.25
func WithComma ¶ added in v0.2.25
func WithComma(c rune) ParseCSVOption
func WithComment ¶ added in v0.2.25
func WithComment(c rune) ParseCSVOption
func WithFieldsPerRecord ¶ added in v0.2.25
func WithFieldsPerRecord(f int) ParseCSVOption
func WithLazyQuotes ¶ added in v0.2.25
func WithLazyQuotes(l bool) ParseCSVOption
func WithTrimLeadingSpace ¶ added in v0.2.25
func WithTrimLeadingSpace(t bool) ParseCSVOption