Documentation
¶
Index ¶
- func Float32Ptr(v float32) *float32
- func GetTemplateByBytes(name string, data map[string]interface{}) ([]byte, error)
- func GetTemplateByString(name string, data map[string]interface{}) (string, error)
- func Int32Ptr(v int32) *int32
- func IsCommandAvailable(cmd string) bool
- func LoadTemplates(files embed.FS) error
- func NewTemplateByString(format string, data map[string]interface{}) (string, error)
- type Data
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Float32Ptr ¶ added in v0.13.0
Float32Ptr takes a float32 value and returns a pointer to that value. This can be useful for passing float32 values to functions that require a pointer.
func GetTemplateByBytes ¶ added in v0.1.0
GetTemplateByBytes returns the parsed template as a byte slice. It returns an error if the template processing fails.
func GetTemplateByString ¶ added in v0.1.0
GetTemplateByString returns the parsed template as a string. It returns an error if the template processing fails.
func Int32Ptr ¶ added in v0.13.0
Int32Ptr takes an int32 value and returns a pointer to that value. This can be useful for passing int32 values to functions that require a pointer.
func IsCommandAvailable ¶
IsCommandAvailable checks if a given command is available in the system's PATH. It takes a string argument 'cmd' which represents the command to check. It returns true if the command is found, otherwise false.
func LoadTemplates ¶
LoadTemplates loads all the templates found in the templates directory from the embedded filesystem. It returns an error if reading the directory or parsing any template fails.
func NewTemplateByString ¶ added in v0.1.0
NewTemplateByString parses a template from a string and executes it with the provided data. It returns the resulting string or an error if the template parsing or execution fails.
Types ¶
type Data ¶
type Data map[string]interface{}
Data defines a custom type for the template data.
func ConvertToMap ¶ added in v0.2.1
ConvertToMap takes a slice of strings in the format "key=value" and converts it into a Data map. Each string in the slice is split into a key and value pair using the first occurrence of the "=" character. If a string does not contain the "=" character, it is ignored. The resulting map contains the keys and values from the input slice.
Args:
args ([]string): A slice of strings where each string is in the format "key=value".
Returns:
Data: A map where the keys and values are derived from the input slice.