fs

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(path string) string

Escape replaces first '#' with '##' and then replaces all remaining ':' with '#'.

func FSContainsFiles

func FSContainsFiles(fsys fs.FS) (bool, error)

FSContainsFiles returns true if the given fs.FS contains any files, and false otherwise.

func HashDirectory added in v0.6.0

func HashDirectory(root string) (string, error)

HashDirectory computes a deterministic SHA-256 hash over all files in a directory tree. Files are sorted by their relative path, and each file contributes its relative path (null-terminated) followed by its contents to the hash. An empty directory produces the hash of an empty input.

func HashFS added in v0.6.0

func HashFS(fsys fs.FS) (string, error)

HashFS computes a deterministic SHA-256 hash over all files in an fs.FS. Files are sorted by path, each contributing its path (null-terminated) followed by its contents.

func MapFS

func MapFS(m map[string]string) fs.FS

func NewEscapeFS

func NewEscapeFS(f fs.ReadDirFS) fs.ReadDirFS

func NewFilterFS

func NewFilterFS(fs fs.FS, include []string, exclude []string) (fs.FS, error)

NewFilterFS takes an fs.FS instance and lists of glob strings to be included and excluded. On Open(), it'll return `fs.ErrNotExist` if the file is excluded, or if the include list is non-empty and the file wasn't explicitly included. Both glob lists expect /-separated paths. On ReadDir(), the same logic applies, except that any directory is returned, unless it is explicitly excluded. With typical usage, it'll result in many empty directories; but for our use case of feeding the `fs.FS` into OPA's bundle build machinery, that doesn't make a difference. Filtering by ReadDir() lets us avoid listing files that we'll not allow access to. When building a bundle using fs.FS, not doing this would give us "file does not exist" errors for excluded files.

func NewTraceFS

func NewTraceFS(fsys fs.FS) fs.FS

func Walk

func Walk(fs_ fs.FS)

Types

type FilterFS

type FilterFS struct {
	// contains filtered or unexported fields
}

func (*FilterFS) Open

func (f *FilterFS) Open(name string) (fs.File, error)

type TraceFS

type TraceFS struct {
	// contains filtered or unexported fields
}

func (*TraceFS) Open

func (t *TraceFS) Open(p string) (fs.File, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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