file

package
v1.16.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package file virtualizes file systems for mock testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessLines added in v1.16.0

func ProcessLines(content string) iter.Seq2[int, string]

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

func ReadLines(ppfmt pp.PP, path string) (lines iter.Seq2[int, string], ok bool)

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

func ReadString(ppfmt pp.PP, path string) (string, bool)

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

func RequireAbsolutePath(ppfmt pp.PP, path string) (fixedPath string, ok bool)

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

func SetFSForTesting(vfs fs.FS)

SetFSForTesting replaces the backing file system used by this package. It exists to support tests in dependent packages.

Types

This section is empty.

Jump to

Keyboard shortcuts

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