Documentation
¶
Index ¶
- Variables
- func Available() []string
- func IsMarkdownFile(path string) bool
- func Register(scheme string, fn SourceFunc)
- type Directory
- type File
- type Source
- type SourceFunc
- type Stdin
- type VirtualFile
- func (f *VirtualFile) Close() error
- func (f *VirtualFile) IsDir() bool
- func (f *VirtualFile) ModTime() time.Time
- func (f *VirtualFile) Mode() fs.FileMode
- func (f *VirtualFile) Name() string
- func (f *VirtualFile) Size() int64
- func (f *VirtualFile) Stat() (fs.FileInfo, error)
- func (f *VirtualFile) Sys() any
Constants ¶
This section is empty.
Variables ¶
var ( // Root represents the root of a source filesystem. Root = "." // ErrSourceNotFound is returned by New() when the source was not found by the scheme. ErrSourceNotFound = errors.New("source not found") )
Functions ¶
func Available ¶
func Available() []string
Available returns a slice of all registered source schemes.
func IsMarkdownFile ¶
IsMarkdownFile checks if the file path has a Markdown extension.
func Register ¶
func Register(scheme string, fn SourceFunc)
Register adds the source function by a scheme. If the scheme is already registered, this is a no-op.
Types ¶
type Directory ¶
type Directory struct {
// contains filtered or unexported fields
}
Directory is a source that reads from a directory on the filesystem.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is a source that reads from a single file.
type Source ¶
type Source interface {
fs.FS
// Watch watches the filesystem for changes to Markdown files, sending their paths over the channel files.
// Errors should be sent over the channel errors.
Watch(files chan<- string, errors chan<- error)
// Close closes the source.
Close() error
}
Source represents a filesystem with Markdown files.
func New ¶
New creates a new source given a URI in the format '{scheme}://{path}', i.e. 'file://path/to/markdown/file.md'. If the scheme is not found, ErrSourceNotFound is returned.
func NewDirectory ¶
NewDirectory creates a new directory source.
type SourceFunc ¶
SourceFunc represents a function that creates a source from the given path.
type Stdin ¶
type Stdin struct {
// contains filtered or unexported fields
}
Stdin is a source that reads from standard input.
type VirtualFile ¶
VirtualFile is a fs.File implementation that wraps a buffer.
func NewVirtualFile ¶
func NewVirtualFile(name string) *VirtualFile
NewVirtualFile creates a new virtual file with the given name.
func (*VirtualFile) Close ¶
func (f *VirtualFile) Close() error
func (*VirtualFile) IsDir ¶
func (f *VirtualFile) IsDir() bool
func (*VirtualFile) ModTime ¶
func (f *VirtualFile) ModTime() time.Time
func (*VirtualFile) Mode ¶
func (f *VirtualFile) Mode() fs.FileMode
func (*VirtualFile) Name ¶
func (f *VirtualFile) Name() string
func (*VirtualFile) Size ¶
func (f *VirtualFile) Size() int64
func (*VirtualFile) Sys ¶
func (f *VirtualFile) Sys() any