Documentation
¶
Overview ¶
Package sys provides os level helper functions for interacting with the system
Index ¶
- func Abs(target string) (result string, err error)
- func AllDirs(root string, opts ...*opt.Opt) (result []string, err error)
- func AllFiles(root string, opts ...*opt.Opt) (result []string, err error)
- func AllPaths(root string, opts ...*opt.Opt) (result []string, err error)
- func Base(src string) (result string)
- func Copy(src, dst string, opts ...*opt.Opt) (err error)
- func CopyFile(src, dst string, opts ...*opt.Opt) (err error)
- func Dir(src string) (result string)
- func Dirs(target string) (result []string)
- func Exists(src string) bool
- func Files(target string) (result []string)
- func Home() (result string, err error)
- func IsDarwin() (result bool)
- func IsDir(src string) bool
- func IsFile(src string) bool
- func IsLinux() (result bool)
- func IsSymlink(src string) bool
- func IsSymlinkDir(src string) bool
- func IsSymlinkFile(src string) bool
- func MD5(target string) (result string, err error)
- func MkdirP(target string, perms ...uint32) (dir string, err error)
- func Move(src, dst string) (err error)
- func Paths(target string) (result []string)
- func Pwd() (pwd string)
- func ReadDir(dirname string) (names []string, err error)
- func ReadFile(target string) (result string, err error)
- func ReadLines(target string) (result []string, err error)
- func ReadYaml(target string) (obj map[string]interface{}, err error)
- func Remove(target string) error
- func RemoveAll(target string) error
- func SharedDir(first, second string) (result string)
- func Size(src string) (size int64)
- func SlicePath(target string, i, j int) (result string)
- func Symlink(oldname, newname string) error
- func SymlinkTarget(src string) (target string, err error)
- func Touch(target string) (path string, err error)
- func TrimExt(target string) string
- func TrimProtocol(target string) string
- func Walk(root string, walkFn WalkFunc, opts ...*opt.Opt) (err error)
- func WriteFile(target string, data []byte, perms ...uint32) (err error)
- func WriteFileA(target string, data string, perms ...uint32) (err error)
- func WriteLines(target string, lines []string, perms ...uint32) (err error)
- func WriteStream(reader io.Reader, dest string, perms ...uint32) (err error)
- func WriteYaml(target string, obj interface{}, perms ...uint32) (err error)
- type FileInfo
- func (info *FileInfo) AbsPath() (path string, err error)
- func (info *FileInfo) IsDir() bool
- func (info *FileInfo) IsFile() bool
- func (info *FileInfo) IsSymlink() bool
- func (info *FileInfo) IsSymlinkDir() bool
- func (info *FileInfo) IsSymlinkFile() bool
- func (info *FileInfo) Mode() os.FileMode
- func (info *FileInfo) ModeTime() time.Time
- func (info *FileInfo) Name() string
- func (info *FileInfo) Path() string
- func (info *FileInfo) Size() int64
- func (info *FileInfo) SymlinkTarget() (target string, err error)
- func (info *FileInfo) Sys() interface{}
- type WalkFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllDirs ¶
AllDirs returns a list of all dirs recursively for the given root path in a deterministic order. Follows links by default, but can be stopped with &Opt{"follow", false}. Paths are distinct.
func AllFiles ¶
AllFiles returns a list of all files recursively for the given root path in a deterministic order. Follows links by default, but can be stopped with &Opt{"follow", false}. Paths are distinct.
func AllPaths ¶
AllPaths returns a list of all paths recursively for the given root path in a deterministic order including the root path as first entry. Follows links by default, but can be stopped with &Opt{"follow", false}. Paths are distinct.
func Copy ¶
Copy copies src to dst recursively, creating destination directories as needed. Handles globbing e.g. Copy("./*", "../") The dst will be copied to if it is an existing directory. The dst will be a clone of the src if it doesn't exist. Doesn't follow links by default but can be turned on with &Opt{"follow", true}
func CopyFile ¶
CopyFile copies a single file from src to dsty, creating destination directories as needed. The dst will be copied to if it is an existing directory. The dst will be a clone of the src if it doesn't exist. Doesn't follow links by default but can be turned on with &Opt{"follow", true}
func IsSymlinkDir ¶
IsSymlinkDir returns true if the given symlink's target is a directory
func IsSymlinkFile ¶
IsSymlinkFile returns true if the given symlink's target is a directory
func MkdirP ¶
MkdirP creates the target directory and any parent directories needed and returns the ABS path of the created directory
func Move ¶
Move the src path to the dst path. If the dst already exists and is not a directory src will replace it. If there is an error it will be of type *LinkError. Wraps os.Rename but fixes the issue where dst name is required
func ReadDir ¶
ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename.
func ReadYaml ¶
ReadYaml reads the target file and returns a map[string]interface{} data structure representing the yaml read in.
func Remove ¶
Remove the given target file or empty directory. If there is an error it will be of type *PathError
func RemoveAll ¶
RemoveAll removes the target path and any children it contains. It removes everything it can but returns the first error it encounters. If the target path does not exist nil is returned
func Symlink ¶
Symlink creates newname as a symbolic link to oldname. If there is an error, it will be of type *LinkError. newname is created as ???
func SymlinkTarget ¶
SymlinkTarget follows the symlink to get the path for the target
func TrimProtocol ¶
TrimProtocol removes well known protocol prefixes
func Walk ¶
Walk extends the filepath.Walk to allow for it to walk symlinks by default but can be turned off with &Opt{"follow", false}
func WriteFileA ¶
WriteFileA is a pass through to ioutil.WriteFile with default permissions
func WriteLines ¶
WriteLines is a pass through to ioutil.WriteFile with default permissions
func WriteStream ¶
WriteStream reads from the io.Reader and writes to the given file using io.Copy thus never filling memory i.e. streaming. dest will be overwritten if it exists.
Types ¶
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
FileInfo wraps the os.FileInfo interface and provide additional helper functions
func Lstat ¶
Lstat wraps os.Lstate to give back a FileInfo Resolves home dir and relative dir pathing into absolute paths
func (*FileInfo) IsSymlinkDir ¶
IsSymlinkDir returns true if the symlink's target is a directory
func (*FileInfo) IsSymlinkFile ¶
IsSymlinkFile returns true if the symlink's target is a file
func (*FileInfo) ModeTime ¶
ModeTime implements os.FileInfo and is the modification time of the file
func (*FileInfo) SymlinkTarget ¶
SymlinkTarget follows the symlink to get the path for the target