embed

Imports

Imports #

"errors"
"internal/bytealg"
"internal/stringslite"
"io"
"io/fs"
"time"

Constants & Variables

_ var #

var _ fs.ReadDirFS = FS{...}

_ var #

var _ fs.ReadFileFS = FS{...}

_ var #

var _ fs.FileInfo = *ast.CallExpr

_ var #

var _ fs.DirEntry = *ast.CallExpr

_ var #

var _ io.Seeker = *ast.CallExpr

_ var #

var _ io.ReaderAt = *ast.CallExpr

dotFile var #

dotFile is a file for the root directory, which is omitted from the files list in a FS.

var dotFile = *ast.UnaryExpr

Structs

FS struct #

An FS is a read-only collection of files, usually initialized with a //go:embed directive. When declared without a //go:embed directive, an FS is an empty file system. An FS is a read-only value, so it is safe to use from multiple goroutines simultaneously and also safe to assign values of type FS to each other. FS implements fs.FS, so it can be used with any package that understands file system interfaces, including net/http, text/template, and html/template. See the package documentation for more details about initializing an FS.

type FS struct {
files *[]file
}

file struct #

A file is a single file in the FS. It implements fs.FileInfo and fs.DirEntry.

type file struct {
name string
data string
hash [16]byte
}

openDir struct #

An openDir is a directory open for reading.

type openDir struct {
f *file
files []file
offset int
}

openFile struct #

An openFile is a regular file open for reading.

type openFile struct {
f *file
offset int64
}

Functions

Close method #

func (f *openFile) Close() error

Close method #

func (d *openDir) Close() error

Info method #

func (f *file) Info() (fs.FileInfo, error)

IsDir method #

func (f *file) IsDir() bool

ModTime method #

func (f *file) ModTime() time.Time

Mode method #

func (f *file) Mode() fs.FileMode

Name method #

func (f *file) Name() string

Open method #

Open opens the named file for reading and returns it as an [fs.File]. The returned file implements [io.Seeker] and [io.ReaderAt] when the file is not a directory.

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

Read method #

func (d *openDir) Read([]byte) (int, error)

Read method #

func (f *openFile) Read(b []byte) (int, error)

ReadAt method #

func (f *openFile) ReadAt(b []byte, offset int64) (int, error)

ReadDir method #

func (d *openDir) ReadDir(count int) ([]fs.DirEntry, error)

ReadDir method #

ReadDir reads and returns the entire named directory.

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

ReadFile method #

ReadFile reads and returns the content of the named file.

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

Seek method #

func (f *openFile) Seek(offset int64, whence int) (int64, error)

Size method #

func (f *file) Size() int64

Stat method #

func (f *openFile) Stat() (fs.FileInfo, error)

Stat method #

func (d *openDir) Stat() (fs.FileInfo, error)

String method #

func (f *file) String() string

Sys method #

func (f *file) Sys() any

Type method #

func (f *file) Type() fs.FileMode

lookup method #

lookup returns the named file, or nil if it is not present.

func (f FS) lookup(name string) *file

readDir method #

readDir returns the list of files corresponding to the directory dir.

func (f FS) readDir(dir string) []file

sortSearch function #

sortSearch is like sort.Search, avoiding an import.

func sortSearch(n int, f func(int) bool) int

split function #

split splits the name into dir and elem as described in the comment in the FS struct above. isDir reports whether the final trailing slash was present, indicating that name is a directory.

func split(name string) (dir string, elem string, isDir bool)

Generated with Arrow