Package file
file wraps around the standard functions to simplify reading and writing on disk
- Variables
- func Clean(fn string) error
- func Copy(from, to string) error
- func Delete(fn string) error
- func Each(dirname string, recursive bool, fnc func(string, string, string, bool, os.FileInfo)) error
- func Exists(fn string) bool
- func FakeHomeDir(dir string) string
- func GetAbsolutePath(fn string) (string, error)
- func GetAbsolutePathByApp(fn string) (string, error)
- func GetHomeDir() string
- func IsDir(fn string) bool
- func IsFile(fn string) bool
- func IsSymlink(fn string) bool
- func Read(fn string) (string, error)
- func ReadBlocks(fn string, delim []string, fnc func(string) (string, error)) (string, error)
- func ReadDir(dn string) ([]string, error)
- func ReadUntil(fn string, delim []string) (string, string, int, error)
- func Rename(from, to string) error
- func SetHomeDir() string
- func Size(fn string) (int64, error)
- func Time(fn string) (time.Time, time.Time, time.Time, error)
- func Write(fn, str string, append bool) error
Package files
file.go
file_darwin.go
Variables
var HomeDir string
func Clean(fn string) error
func Copy(from, to string) error
func Delete(fn string) error
func Each(dirname string, recursive bool, fnc func(string, string, string, bool, os.FileInfo)) error
func Exists(fn string) bool
func FakeHomeDir(dir string) string
func GetAbsolutePath(fn string) (string, error)
GetAbsolutePath returns the absolute path to a file or dir
if it is a relative path it is relative to the current working directory
▾ Example
Code:
converted, err := file.GetAbsolutePath(".")
fmt.Println(converted, err)
func GetAbsolutePathByApp(fn string) (string, error)
GetAbsolutePathByApp returns the absolute path to a file or dir
if it is a relative path it is relative to the Go Application source or binary
func GetHomeDir() string
func IsDir(fn string) bool
func IsFile(fn string) bool
func IsSymlink(fn string) bool
func Read(fn string) (string, error)
▾ Example
Code:
str, _ := file.Read("test.txt")
fmt.Println(str)
Output:
Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
func ReadBlocks(fn string, delim []string, fnc func(string) (string, error)) (string, error)
func ReadDir(dn string) ([]string, error)
func ReadUntil(fn string, delim []string) (string, string, int, error)
func Rename(from, to string) error
func SetHomeDir() string
func Size(fn string) (int64, error)
▾ Example
Code:
size, _ := file.Size("test.txt")
fmt.Println(size)
Output:
429
func Time(fn string) (time.Time, time.Time, time.Time, error)
func Write(fn, str string, append bool) error