Skip to content

Interface

Every driver implements the contract defined in go-filesystems/interface (package filesystem):

type Filesystem interface {
    Close() error
    ReadFile(path string) ([]byte, error)
    ListDir(path string) ([]DirEntry, error)
    Stat(path string) (Stat, error)
    WriteFile(path string, data []byte, perm os.FileMode) error
    ReadLink(path string) (string, error)
    MkDir(path string, perm os.FileMode) error
    DeleteFile(path string) error
    DeleteDir(path string) error
    Rename(oldPath, newPath string) error
}

Optional capabilities are probed via type assertion:

  • Labeller — volume label get/set.
  • Resizer — grow/shrink (returns ErrShrinkUnsupported where shrink is impossible).

See the package reference for the full API, including DirEntry and Stat.