Documentation ¶
Overview ¶
file wraps around the standard functions to simplify reading and writing on disk
Index ¶
- Variables
- func Clean(fn string) error
- func Copy(from, to string) error
- func Delete(fn string) error
- func Each(dirname string, recursive bool, ...) 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
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var HomeDir string
Functions ¶
func FakeHomeDir ¶
func GetAbsolutePath ¶
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 ¶
package main import ( "fmt" "simonwaldherr.de/go/golibs/file" ) func main() { converted, err := file.GetAbsolutePath(".") fmt.Println(converted, err) }
Output:
func GetAbsolutePathByApp ¶
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 ¶
func GetHomeDir() string
func Read ¶
Example ¶
package main import ( "fmt" "simonwaldherr.de/go/golibs/file" ) func main() { 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 ¶
func SetHomeDir ¶
func SetHomeDir() string
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.