Documentation ¶
Overview ¶
Package fs provides filesystem-related utilities.
Index ¶
- func BaseName(path string) string
- func Copy(src, dst string) error
- func CopyWithMask(src, dst string, mask fs.FileMode) error
- func CreateTemp(dir, pattern string, perm os.FileMode) (*os.File, error)
- func FileExists(path string) bool
- func FileIsReadable(path string) bool
- func IsDir(path string) bool
- func LoadJSON(path string, data any) error
- func LoadJSONFromFS(fsys fs.FS, path string, data any) error
- func LoadYAML(path string, data any) error
- func LoadYAMLFromFS(fsys fs.FS, path string, data any) error
- func MoveFile(src, dst string) (err error)
- func SanitizeName(name string) string
- func SaveJSON(path string, data any, format bool) error
- func SaveJSONWithMode(path string, data any, format bool, mode os.FileMode) error
- func SaveYAML(path string, data any) error
- func SaveYAMLWithMode(path string, data any, mode os.FileMode) error
- func Split(path string) []string
- func TrimExtension(path string) string
- func UniquePaths(paths ...string) ([]string, error)
- func UnsanitizeName(name string) string
- func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyWithMask ¶ added in v1.40.0
CopyWithMask src to dst. src may be a directory, file, or symlink.
func CreateTemp ¶ added in v1.74.0
CreateTemp is essentially the same as os.CreateTemp, except it allows you to specify the file mode of the newly created file.
func FileExists ¶
FileExists returns true if the path points to a regular file.
func FileIsReadable ¶ added in v1.57.0
FileIsReadable returns true if the path points to a regular file that we have permission to read.
func LoadJSONFromFS ¶ added in v1.50.0
LoadJSONFromFS data from the specified filesystem path.
func LoadYAMLFromFS ¶ added in v1.50.0
LoadYAMLFromFS data from the specified filesystem path.
func MoveFile ¶
MoveFile moves a file in the file system or across volumes, using rename if possible, but falling back to copying the file if not. This will error if either src or dst are not regular files.
func SanitizeName ¶
SanitizeName sanitizes a file name by replacing invalid characters.
func SaveJSONWithMode ¶ added in v1.40.0
SaveJSONWithMode data to the specified path.
func SaveYAMLWithMode ¶ added in v1.40.0
SaveYAMLWithMode data to the specified path.
func Split ¶
Split a path into its component parts. In the case of a full path, the first element will be filepath.Separator, possibly prefixed by a volume name. In the case of a relative path, the first element will be ".".
func TrimExtension ¶
TrimExtension trims any extension from the path.
func UniquePaths ¶ added in v1.26.0
UniquePaths returns a list of unique paths from the given paths, pruning out paths that are a subset of another.
func UnsanitizeName ¶
UnsanitizeName reverses the effects of a call to SanitizeName.
Types ¶
This section is empty.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package paths provides platform-specific standard paths.
|
Package paths provides platform-specific standard paths. |
Package safe provides safe, atomic saving of files.
|
Package safe provides safe, atomic saving of files. |
Package tar provides simple tar extraction.
|
Package tar provides simple tar extraction. |
Package zip provides simple zip extraction.
|
Package zip provides simple zip extraction. |