Documentation
¶
Overview ¶
Package embedfs adapts any fs.FS (including embed.FS) to vfs.Storage.
The backend is read-only: WriteFile and DeleteFile return vfs.ErrReadOnly. Suitable for chatbot/knowledge-base use cases where the corpus is fixed at compile time and the model only reads.
import _ "embed" //go:embed knowledge/*.md var knowledgeFS embed.FS knowledge, _ := fs.Sub(knowledgeFS, "knowledge") storage := embedfs.NewStorage(knowledge)
Storage satisfies vfs.Searchable with case-insensitive substring matching against file contents — same syntax as vfs/memory.
Index ¶
- type Storage
- func (s *Storage) DeleteFile(_ context.Context, p string) error
- func (s *Storage) ListFiles(ctx context.Context) ([]vfs.FileMeta, error)
- func (s *Storage) ReadFile(ctx context.Context, p string) ([]byte, vfs.FileMeta, error)
- func (s *Storage) Search(ctx context.Context, query string) ([]string, error)
- func (s *Storage) SearchSyntax() string
- func (s *Storage) WriteFile(_ context.Context, p string, _ []byte, _ string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage wraps an fs.FS as a read-only vfs.Storage.
func NewStorage ¶
NewStorage wraps fsys. The fsys is consulted on every call; nothing is cached.
Caller-bound subdirectories: pass fs.Sub(fsys, "data") if your embed includes a parent prefix you want to hide from the model.
func (*Storage) DeleteFile ¶
DeleteFile always returns vfs.ErrReadOnly.
func (*Storage) ListFiles ¶
ListFiles walks the entire fs and returns every file (no directories). Paths are relative; deterministic alphabetical order.
func (*Storage) SearchSyntax ¶
SearchSyntax describes the query syntax this backend accepts.