Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package fs provides utility functions for directory operations, such as listing files with a specific extension.
Package fs provides utility functions for secure file operations, including path validation and extension whitelisting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListFiles ¶
ListFiles returns absolute file paths under dirPath whose extension matches ext.
Parameters:
- dirPath: the directory to search
 - ext: the file extension to match (e.g., ".json")
 
Returns:
- []string: absolute file paths matching the extension
 - error: if the directory cannot be read
 
func SafeReadFile ¶
SafeReadFile reads a file from disk securely.
It enforces: - Path cleaning (removes ../ etc.) - Absolute path resolution - Ensures the file is within the trusted baseDir - Only allows files with extensions in allowExt (e.g. {".json":{}, ".yaml":{}})
Parameters:
- path: the file path to read
 - baseDir: the trusted base directory
 - allowExt: a set of allowed file extensions
 
Returns:
- file contents as []byte
 - error if the file cannot be read or does not meet security checks
 
Types ¶
This section is empty.
 Click to show internal directories. 
   Click to hide internal directories.