Documentation ¶
Overview ¶
Package osutil implements some OS utility functions.
Package osutil implements some OS utility functions.
Index ¶
- func AbsFilepath(path string) (string, error)
- func CreateFileWithLines(filename string, lines []string, lineSuffix string, useBuffer bool) error
- func EmptyAll(name string) error
- func EnvExists(fields ...string) (missing []string, haveAll bool)
- func EnvFiltered(rx *regexp.Regexp) map[string]string
- func Exists(name string) (bool, error)
- func FileModAge(name string) (time.Duration, error)
- func FileModAgeFromInfo(fi os.FileInfo) time.Duration
- func FinfosToFilepaths(dir string, fis []os.FileInfo) []string
- func GetFileInfo(path string) (os.FileInfo, error)
- func UserGoSrcDir() (string, error)
- type EnvVar
- type FileInfoMore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbsFilepath ¶
AbsFilepath returns an absolute filepath, using the user's current / home directory if indicated in the filepath string.
func CreateFileWithLines ¶
CreateFileWithLines creates a file and writes lines to it. It will optionally add a `lineSuffix` (e.g. `"\n"`) and use `bufio`.
func EmptyAll ¶
EmptyAll will delete all contents of a directory, leaving the provided directory. This is different from os.Remove which also removes the directory provided.
func EnvFiltered ¶
EnvFiltered returns a map[string]string of environment variables that match a regular expression.
func FileModAge ¶
FileModAge returns a time.Duration representing the age of the named file from FileInfo.ModTime().
func FileModAgeFromInfo ¶
FileModAgeFromInfo returns the file last modification age as a time.Duration.
func FinfosToFilepaths ¶
FinfosToFilepaths returns a slice of string from a directory and sli=ce of `os.FileInfo`.
func GetFileInfo ¶
GetFileInfo returns an os.FileInfo from a filepath.
func UserGoSrcDir ¶ added in v0.0.2
Types ¶
type FileInfoMore ¶
FileInfoMore provides a struct hold FileInfo with additional information.
func NewFileInfoMoreFromPath ¶
func NewFileInfoMoreFromPath(path string) (FileInfoMore, error)
NewFileInfoMoreFromPath returns a FileInfoMore struct populatig both FileInfo and ModAge (last modification time).