mdfs

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

package mdfs provides a file system that wraps a directory and an embed.FS. it prioritizes the directory FS and falls back to the embedded FS if the file cannot be found on disk. This is useful during development or when deploying with assets not embedded in the binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

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

FS wraps a directory and an embed FS that are expected to have the same contents. it prioritizes the directory FS and falls back to the embedded FS if the file cannot be found on disk. This is useful during development or when deploying with assets not embedded in the binary.

func New

func New(embed fs.FS, dir, env string) FS

NewFallbackFS returns a new FS that wraps the given directory and embedded FS. the embed.FS is expected to embed the same files as the directory FS.

func (FS) Open

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

Open opens the named file.

When Open returns an error, it should be of type *PathError with the Op field set to "open", the Path field set to name, and the Err field describing the problem.

Open should reject attempts to open names that do not satisfy ValidPath(name), returning a *PathError with Err set to ErrInvalid or ErrNotExist.

func (FS) ReadFile

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

ReadFile reads the named file from the file system fs and returns its contents. It uses the custom Open method to open the file.

Jump to

Keyboard shortcuts

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