Documentation
¶
Overview ¶
Package file virtualizes file systems for mock testing.
Index ¶
- func ProcessLines(content string) iter.Seq2[int, string]
- func ReadLines(ppfmt pp.PP, path string) (lines iter.Seq2[int, string], ok bool)
- func ReadString(ppfmt pp.PP, path string) (string, bool)
- func RequireAbsolutePath(ppfmt pp.PP, path string) (fixedPath string, ok bool)
- func ResetFSForTesting()
- func SetFSForTesting(vfs fs.FS)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProcessLines ¶ added in v1.16.0
ProcessLines returns an iterator over non-blank, non-comment lines in content. Each yielded pair is (1-based line number, trimmed content after stripping # comments).
func ReadLines ¶ added in v1.16.0
ReadLines reads a file and returns an iterator over its non-blank, non-comment lines. Each yielded pair is (1-based line number, trimmed content after stripping # comments). The path must be absolute; relative paths are rejected. If the file cannot be read, lines is nil and ok is false.
func ReadString ¶
ReadString reads the content of the file at path. The path must be absolute; relative paths are rejected.
func RequireAbsolutePath ¶ added in v1.16.0
RequireAbsolutePath checks that path is absolute. On failure, it prints a generic error and returns the suggested fix ("/"+path). Callers may use fixedPath for context-specific hints.
func ResetFSForTesting ¶ added in v1.16.2
func ResetFSForTesting()
ResetFSForTesting restores the default backing file system after tests.
func SetFSForTesting ¶ added in v1.16.2
SetFSForTesting replaces the backing file system used by this package. It exists to support tests in dependent packages.
Types ¶
This section is empty.