-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
example_test.go
44 lines (36 loc) · 841 Bytes
/
example_test.go
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package copy
import (
"fmt"
"os"
"strings"
)
func ExampleCopy() {
err := Copy("test/data/example", "test/data.copy/example")
fmt.Println("Error:", err)
info, _ := os.Stat("test/data.copy/example")
fmt.Println("IsDir:", info.IsDir())
// Output:
// Error: <nil>
// IsDir: true
}
func ExampleOptions() {
err := Copy(
"test/data/example",
"test/data.copy/example_with_options",
Options{
Skip: func(info os.FileInfo, src, dest string) (bool, error) {
return strings.HasSuffix(src, ".git-like"), nil
},
OnSymlink: func(src string) SymlinkAction {
return Skip
},
PermissionControl: AddPermission(0200),
},
)
fmt.Println("Error:", err)
_, err = os.Stat("test/data.copy/example_with_options/.git-like")
fmt.Println("Skipped:", os.IsNotExist(err))
// Output:
// Error: <nil>
// Skipped: true
}