forked from 3JoB/vfs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_os_test.go
More file actions
27 lines (23 loc) · 672 Bytes
/
example_os_test.go
File metadata and controls
27 lines (23 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package vfs_test
import (
"fmt"
"github.com/lordofscripts/vfs"
)
func ExampleOsFS() {
// Create a vfs accessing the filesystem of the underlying OS
osFS := vfs.OS()
err := osFS.Mkdir("/tmp/vfs_example", 0777)
if err != nil {
fmt.Printf("Error creating directory: %s\n", err)
}
// Convenience method
f, err := vfs.Create(osFS, "/tmp/vfs_example/example.txt")
// f, err := osFS.OpenFile("/tmp/vfs/example.txt", os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
fmt.Printf("Could not create file: %s\n", err)
}
defer f.Close()
if _, err := f.Write([]byte("VFS working on your filesystem")); err != nil {
fmt.Printf("Error writing to file: %s\n", err)
}
}