Documentation
¶
Index ¶
- Constants
- func AddIgnoreRules(ignoreFilePath string, rules []string) ([]string, error)
- func ListIgnoreRules(ignoreFilePath string) ([]string, error)
- func ReadIgnoreFile(path string) ([]string, error)
- func RemoveIgnoreRule(ignoreFilePath string, pattern string) error
- func Walk(root, ignoreFile string, fn func(path string, info os.FileInfo) error) error
- func WalkCtx(ctx context.Context, root, ignoreFile string, ...) error
- func WriteFileAtomic(path string, data []byte, perm os.FileMode) error
Constants ¶
const DefaultDirPerm os.FileMode = 0755
DefaultDirPerm is the default permission for created directories.
const DefaultFilePerm os.FileMode = 0644
DefaultFilePerm is the default permission for created files.
Variables ¶
This section is empty.
Functions ¶
func AddIgnoreRules ¶
AddIgnoreRules appends the given rules to the ignore file, skipping duplicates and preserving existing order. Returns the rules actually added.
func ListIgnoreRules ¶
ListIgnoreRules reads the ignore file at path and returns all rules. Returns nil if the file does not exist.
func ReadIgnoreFile ¶
ReadIgnoreFile reads an ignore file and returns the active pattern lines. Comments (lines starting with '#') and blank lines are excluded. A UTF-8 BOM at the start of the file is stripped. Returns nil if the file does not exist.
func RemoveIgnoreRule ¶
RemoveIgnoreRule removes the first rule matching the given pattern from the ignore file. Returns an error if the rule is not found.
func Walk ¶
Walk walks the file tree rooted at root, invoking fn for every file not excluded by the ignore file. It is equivalent to WalkCtx with context.Background. ignoreFile defaults to ".driftignore" when empty. Symbolic links are not followed (filepath.WalkDir semantics). The .drift directory is always skipped.
func WalkCtx ¶
func WalkCtx(ctx context.Context, root, ignoreFile string, fn func(path string, info os.FileInfo) error) error
WalkCtx is the context-aware variant of Walk. It honors context cancellation: a cancelled context is surfaced before the walk starts and re-checked between entries, causing the walk to stop descending immediately. ignoreFile defaults to ".driftignore" when empty. Symbolic links are not followed, and the .drift directory is always skipped.
Nested ignore files in subdirectories are honored: a .driftignore in a subdirectory adds rules scoped to that subtree, following gitignore semantics. Patterns starting with "!" negate a previous match, and a trailing "/" restricts a pattern to directories only.
func WriteFileAtomic ¶
WriteFileAtomic writes data to path atomically: it writes to a temp file in the same directory, fsyncs and closes it, applies perm, renames it over the target, and fsyncs the parent directory. On any error the temp file is removed and the target is left untouched. The temp file is closed before the rename so the rename succeeds on platforms (e.g. Windows) that reject renaming an open file.
Types ¶
This section is empty.