Documentation ¶
Index ¶
- Variables
- func Add(args ...int) int
- func AppendSlice(slice []any, value any) []any
- func FileBase(path string) string
- func FileSep() string
- func FileTrimExtFunc(path string) string
- func FilterMatch(pattern string, values []string) ([]string, error)
- func HasSuffix(s, suffix string) bool
- func KeysToMapWithDefault(defaultValue any, keys []string) (map[string]any, error)
- func Last(list any) (any, error)
- func MakeSlice() []any
- func MapString(pattern, replace string, values []string) ([]string, error)
- func Matches(pattern, value string) (bool, error)
- func MustTemplate(fs embed.FS, name string) *template.Template
- func ReplaceAll(s string, old string, new string) string
- func ReplaceAllRegex(pattern, replace, value string) (string, error)
- func SliceContains(slice []any, value any) bool
- func Sub(args ...int) int
- func ToJSON(v any) (string, error)
- func ToJSONPretty(v any) (string, error)
- func WithCommonFuncs(funcMap template.FuncMap) template.FuncMap
- func ZipToMap(keys []string, valuesArg any) (map[string]any, error)
Constants ¶
This section is empty.
Variables ¶
var UtilityFunctions = template.FuncMap{ "split": strings.Split, "join": strings.Join, "basename": filepath.Base, "filterMatch": FilterMatch, "mapString": MapString, "zipToMap": ZipToMap, "keysToMapWithDefault": KeysToMapWithDefault, "replace": ReplaceAllRegex, "hasSuffix": HasSuffix, "toLower": strings.ToLower, "add": Add, "sub": Sub, "last": Last, "makeSlice": MakeSlice, "appendSlice": AppendSlice, "sliceContains": SliceContains, "matches": Matches, }
Functions ¶
func AppendSlice ¶ added in v0.7.0
AppendSlice appends a value to a slice and returns the updated slice.
func FileSep ¶ added in v0.7.0
func FileSep() string
FileSep returns the separator for the current OS.
func FileTrimExtFunc ¶ added in v0.7.0
FileTrimExtFunc returns the path without the extension.
func FilterMatch ¶ added in v0.7.0
FilterMatch returns a json array by filtering the values array with the regex pattern
func KeysToMapWithDefault ¶ added in v0.7.0
KeysToMapWithDefault returns a json map by mapping the keys array to the static defaultValue Example keysToMapWithDefault(0, ['a', 'b']) => {"a": 0, "b": 0}
func MakeSlice ¶ added in v0.7.0
func MakeSlice() []any
MakeSlice creates and returns a new slice of any type.
func MapString ¶ added in v0.7.0
MapString takes in a regex pattern and replacement as well as a json array of strings roughly `unmarshal value | sed s/pattern/replace/g | marshal`
func ReplaceAll ¶ added in v0.7.0
ReplaceAll replaces all occurrences of old with new in s.
func ReplaceAllRegex ¶ added in v0.7.0
ReplaceAllRegex replaces all occurrences of the regex pattern with the replace string in value.
func SliceContains ¶ added in v0.7.0
SliceContains checks if a slice contains a specific value.
func ToJSONPretty ¶ added in v0.7.0
ToJSONPretty converts any value to a pretty-printed JSON string.
func WithCommonFuncs ¶ added in v0.7.0
Types ¶
This section is empty.