Documentation
¶
Overview ¶
Package iosafety provides defensive file-reading and terminal-output utilities for user-supplied paths and strings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrDirectoryPath indicates a file operation was attempted on a directory. ErrDirectoryPath = errors.New("path points to a directory") // ErrEmptyPath indicates a path argument was empty. ErrEmptyPath = errors.New("path is empty") // ErrPathContainsNUL indicates the path contains a NUL byte. ErrPathContainsNUL = errors.New("path contains NUL byte") )
Sentinel errors for path validation.
Functions ¶
func ReadFile ¶
ReadFile resolves, validates, and reads a user-supplied file path. Returns content, the resolved absolute path, and any error.
func ResolvePath ¶
ResolvePath normalises and validates a user-supplied file path. Returns the absolute path after cleaning, resolving, and stat-checking. Returns an error for empty paths, NUL bytes, directories, or stat failures.
func SanitizeForTerminal ¶
SanitizeForTerminal strips control characters and HTML-escapes the input. Newlines, carriage returns, and tabs are replaced with spaces.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.