util

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Float32Ptr added in v0.13.0

func Float32Ptr(v float32) *float32

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

func GetTemplateByBytes(name string, data map[string]interface{}) ([]byte, error)

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

func GetTemplateByString(name string, data map[string]interface{}) (string, error)

GetTemplateByString returns the parsed template as a string. It returns an error if the template processing fails.

func Int32Ptr added in v0.13.0

func Int32Ptr(v int32) *int32

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

func IsCommandAvailable(cmd string) bool

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

func LoadTemplates(files embed.FS) error

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

func NewTemplateByString(format string, data map[string]interface{}) (string, error)

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

func ConvertToMap(args []string) Data

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.

Jump to

Keyboard shortcuts

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