Documentation ¶
Overview ¶
Package fs provides an interface for a filesystem.
Index ¶
- func Mkdir(name string, perm os.FileMode) error
- func MkdirAll(name string, perm os.FileMode) error
- func Remove(name string) error
- func RemoveAll(name string) error
- func Stat(name string) (os.FileInfo, error)
- func Walk(root string, fn filepath.WalkFunc) error
- type FS
- func (FS) Create(name string) (File, error)
- func (FS) Mkdir(name string, perm os.FileMode) error
- func (FS) MkdirAll(name string, perm os.FileMode) error
- func (FS) Open(name string) (File, error)
- func (FS) Remove(name string) error
- func (FS) RemoveAll(name string) error
- func (FS) Stat(name string) (os.FileInfo, error)
- func (FS) Walk(root string, fn filepath.WalkFunc) error
- type File
- type Filesystem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FS ¶
type FS struct{}
FS provides an implementation for Filesystem interface, wrapping functions from the os package.
type File ¶
type File interface { // Close closes the underlying file. // Default implementation wraps (*os.File).Close. Close() error // Read reads the content of the File. // Default implementation wraps (*os.File).Read. Read([]byte) (int, error) // Readdir gives the file list if the File is a directory. // Default implementation wraps (*os.File).Readdir. Readdir(int) ([]os.FileInfo, error) // Seek moves the current file offset. // Default implementation wraps (*os.File).Seek. Seek(int64, int) (int64, error) // Stat gives the File details. // Default implementation wraps (*os.File).Stat. Stat() (os.FileInfo, error) // Write writes data to the File. // Default implementation wraps (*os.File).Write. Write([]byte) (int, error) }
File is an almost complete interface for the *os.File.
type Filesystem ¶
type Filesystem interface { // Create creates new file or truncates existing one. Create(string) (File, error) // Mkdir creates new directory. It's a nop, if the directory already exists. Mkdir(string, os.FileMode) error // MkdirAll creates new directory and all its parents, if needed. MkdirAll(string, os.FileMode) error // Open opens a file or a directory given by the path. Open(string) (File, error) // Remove deletes a file given by the path. Remove(string) error // Stat gives a file or a directory details, given by the path. RemoveAll(string) error // RemoveAll deletes a file or a directory with all its descendants, given // by the path. Stat(string) (os.FileInfo, error) // Walk walks the file tree starting at root, calling WalkFunc for each file // or directory. Walk(string, filepath.WalkFunc) error }
Filesystem provides an interface for operating on named files.
var Default Filesystem = FS{}
Default is the default implementation of Filesystem, which wraps functions from the os package.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
gotree
Command gotree is a reimplmentation of the Unix tree command in Go.
|
Command gotree is a reimplmentation of the Unix tree command in Go. |
mktree
Command mktree creates a file tree out of tree output read from standard input.
|
Command mktree creates a file tree out of tree output read from standard input. |
Package fsutil is a collection of various filesystem utility functions.
|
Package fsutil is a collection of various filesystem utility functions. |
Package memfs provides an interface for an in-memory filesystem.
|
Package memfs provides an interface for an in-memory filesystem. |
Click to show internal directories.
Click to hide internal directories.