github.com/3JoB/vfs@v1.0.0/example_os_test.go (about) 1 package vfs_test 2 3 import ( 4 "fmt" 5 6 "github.com/3JoB/vfs" 7 ) 8 9 func ExampleOsFS() { 10 // Create a vfs accessing the filesystem of the underlying OS 11 osFS := vfs.OS() 12 err := osFS.Mkdir("/tmp/vfs_example", 0777) 13 if err != nil { 14 fmt.Printf("Error creating directory: %s\n", err) 15 } 16 17 // Convenience method 18 f, err := vfs.Create(osFS, "/tmp/vfs_example/example.txt") 19 // f, err := osFS.OpenFile("/tmp/vfs/example.txt", os.O_CREATE|os.O_RDWR, 0666) 20 if err != nil { 21 fmt.Printf("Could not create file: %s\n", err) 22 } 23 defer f.Close() 24 if _, err := f.Write([]byte("VFS working on your filesystem")); err != nil { 25 fmt.Printf("Error writing to file: %s\n", err) 26 } 27 }