Documentation ¶
Overview ¶
Package fileutil contains utility functions for working with files and directories.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyDirContents ¶
CopyDirContents recursively copies contents of src to dst.
Example ¶
package main import ( "log" "go.astrophena.name/gen/fileutil" ) func main() { if err := fileutil.CopyDirContents("phryne", "fisher"); err != nil { log.Fatal(err) } }
Output:
func CopyFile ¶
CopyFile copies the file src to dst, creating missing directories, if needed.
Example ¶
package main import ( "log" "go.astrophena.name/gen/fileutil" ) func main() { if err := fileutil.CopyFile("/etc/hostname", "/tmp/hostname"); err != nil { log.Fatal(err) } }
Output:
func Exists ¶
Exists returns true if a file or directory does exist and false otherwise.
Example ¶
package main import ( "fmt" "go.astrophena.name/gen/fileutil" ) func main() { if fileutil.Exists("example") { fmt.Println("example exists") } else { fmt.Println("no example!") } }
Output:
func Files ¶
Files returns a slice of files in the directory dir recursively with extensions exts, or an error. If no file extensions are supplied, all files are returned.
Example ¶
package main import ( "fmt" "path/filepath" "go.astrophena.name/gen/fileutil" ) func main() { dir := filepath.Join("testdata/files") fmt.Println(fileutil.Files(dir)) }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.