helpers

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFiles added in v0.0.8

func FindFiles(dirPath string, ext string) ([]string, error)

FindFiles searches for files with a specific extension in the given root directory and its subdirectories.

Parameters:

  • root: The root directory to start the search from.
  • ext: The file extension to search for, or ".*" to match all files. examples: ".md", ".html", ".txt", ".*"

Returns: - []string: A slice of file paths that match the given extension. - error: An error if the search encounters any issues.

func ForEachFile added in v0.0.8

func ForEachFile(dirPath string, ext string, callback func(string) error) ([]string, error)

ForEachFile iterates over all files with a specific extension in a directory and its subdirectories.

Parameters: - dirPath: The root directory to start the search from. - ext: The file extension to search for, or ".*" to match all files. - callback: A function to be called for each file found.

Returns: - []string: A slice of file paths that match the given extension. - error: An error if the search encounters any issues.

func GetContentFiles added in v0.0.8

func GetContentFiles(dirPath string, ext string) ([]string, error)

GetContentFiles searches for files with a specific extension in the given directory and its subdirectories.

Parameters: - dirPath: The directory path to start the search from. - ext: The file extension to search for.

Returns: - []string: A slice of file paths that match the given extension. - error: An error if the search encounters any issues.

func GetEnvOrDefault added in v0.0.8

func GetEnvOrDefault(key, defaultValue string) string

func JsonStringToMap

func JsonStringToMap(jsonString string) (map[string]any, error)

JsonStringToMap parses a JSON string and converts it to a map with string keys and any values

func ReadTextFile added in v0.0.8

func ReadTextFile(path string) (string, error)

ReadTextFile reads the contents of a text file at the given path and returns the contents as a string.

Parameters: - path: the path to the text file.

Returns: - string: the contents of the text file as a string. - error: an error if the file cannot be read.

func StringToFloat added in v0.0.8

func StringToFloat(str string) float64

func StringToInt added in v0.0.8

func StringToInt(str string) int

func WriteTextFile added in v0.0.8

func WriteTextFile(path, content string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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