Documentation
¶
Index ¶
- func CreateDirIfNotExists(dirPath string) error
- func ExtractEmbedFS(embedFS embed.FS, targetDirPath string, replaceMode string, backup bool) error
- func FindFilesInEmbedFS(embedFS embed.FS, pattern string) ([]string, error)
- func IsFileNewer(pathFileA string, pathFileB string) (isANewer bool, newerPath string, olderPath string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDirIfNotExists ¶
CreateDirIfNotExists checks if a directory path exists and creates all necessary parent directories if it does not.
Parameters:
- dirPath: The path of the directory to be verified and created.
Returns:
- error: An error if directory creation fails, or nil if successful/already existing.
func ExtractEmbedFS ¶
func ExtractEmbedFS( embedFS embed.FS, targetDirPath string, replaceMode string, backup bool, ) error
ExtractEmbedFS extracts the directory structure and files from an embed.FS into a target directory.
Supported replaceMode strategies:
- "none": If the local root target directory already exists, aborts extraction immediately without modifying files.
- "all": Completely removes existing target directory contents and recreates all embedded files from scratch.
- "miss": Only writes missing files and directories; keeps existing files intact without overwriting.
- "changed": Compares SHA-256 hashes of local files against embedded ones and overwrites only modified files.
Parameters:
- embedFS: The source embedded filesystem containing files to extract.
- targetDirPath: Local destination directory where files will be written.
- replaceMode: Strategy ("none", "all", "miss", "changed") determining overwrite behavior.
- backup: When true, creates a timestamped backup copy of existing target directory before replacement.
Returns:
- error: An error if directory scanning, backup creation, or file writing fails; nil on success.
func FindFilesInEmbedFS ¶
FindFilesInEmbedFS traverses an embedded filesystem and returns paths of files matching a glob or substring pattern.
Parameters:
- embedFS: The embedded filesystem instance to search.
- pattern: Glob pattern or case-insensitive substring to search for.
Returns:
- matches: A slice of matching file paths relative to the embedded filesystem root.
- err: An error if filesystem traversal encounters an issue.
func IsFileNewer ¶
func IsFileNewer( pathFileA string, pathFileB string, ) ( isANewer bool, newerPath string, olderPath string, err error, )
IsFileNewer compares the modification timestamps of two local files.
Parameters:
- pathFileA: Absolute or relative file path of the first file.
- pathFileB: Absolute or relative file path of the second file.
Returns:
- isANewer: True if pathFileA was modified more recently than pathFileB, false otherwise.
- newerPath: The path of whichever file was modified more recently.
- olderPath: The path of whichever file was modified earlier.
- err: An error if os.Stat fails for either file.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.