Documentation
¶
Overview ¶
Package fsx provides various utility functions for dealing with filesystems.
Index ¶
- func DirAndFile(file string) string
- func DirFS(fpath string) (fs.FS, string, error)
- func Dirs(path string) []string
- func FileExists(filePath string) (bool, error)
- func FileExistsFS(fsys fs.FS, filePath string) (bool, error)
- func Filenames(path string, extensions ...string) []string
- func Files(path string, extensions ...string) []fs.DirEntry
- func FindFilesOnPaths(paths []string, files ...string) []string
- func GoSrcDir(dir string) (absDir string, err error)
- func HasFile(path, file string) bool
- func LatestMod(path string, exts ...string) time.Time
- func RelativeFilePath(file, root string) string
- func Sub(fsys fs.FS, dir string) fs.FS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirAndFile ¶
DirAndFile returns the final dir and file name.
func DirFS ¶
DirFS returns the directory part of given file path as an os.DirFS and the filename as a string. These can then be used to access the file using the FS-based interface, consistent with embed and other use-cases.
func FileExists ¶
FileExists checks whether given file exists, returning true if so, false if not, and error if there is an error in accessing the file.
func FileExistsFS ¶
FileExistsFS checks whether given file exists, returning true if so, false if not, and error if there is an error in accessing the file.
func Filenames ¶
Filenames returns all the file names with given extension(s) in directory in sorted order (if extensions is empty then all files are returned)
func Files ¶
Files returns all the FileInfo's for files with given extension(s) in directory in sorted order (if extensions are empty then all files are returned). In case of error, returns nil.
func FindFilesOnPaths ¶
FindFilesOnPaths attempts to locate given file(s) on given list of paths, returning the full Abs path to each file found (nil if none)
func GoSrcDir ¶
GoSrcDir tries to locate dir in GOPATH/src/ or GOROOT/src/pkg/ and returns its full path. GOPATH may contain a list of paths. From Robin Elkind github.com/mewkiz/pkg.
func LatestMod ¶
LatestMod returns the latest (most recent) modification time for any of the files in the directory (optionally filtered by extension(s) if exts != nil) if no files or error, returns zero time value
func RelativeFilePath ¶
RelativeFilePath returns the file name relative to given root file path, if it is under that root; otherwise it returns the final dir and file name.
Types ¶
This section is empty.