sitefs

package
v1.167.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sitefs presents a list of stored files as an fs.FS, reading a file only when it is opened: a tree can hold thousands of files, and a render opens few of them on most changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Path string
	Size int64
}

Entry is one file of a tree.

type FS

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

FS is a tree of files, implementing fs.ReadDirFS, fs.ReadFileFS and fs.StatFS.

func New

func New(entries []Entry, read Reader) *FS

New makes a tree from entries, reading each file through read when opened.

func (*FS) Open

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

Open opens a file or directory.

func (*FS) ReadDir

func (f *FS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir lists one directory.

func (*FS) ReadFile

func (f *FS) ReadFile(name string) ([]byte, error)

ReadFile reads one file.

func (*FS) Stat

func (f *FS) Stat(name string) (fs.FileInfo, error)

Stat describes a file or directory without reading it.

type Reader

type Reader func(name string) ([]byte, error)

Reader reads one file's bytes, which the caller may then change.

Jump to

Keyboard shortcuts

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