-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_test.go
45 lines (37 loc) · 954 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
45
package aferocopy
import (
"fmt"
"os"
"strings"
"github.com/spf13/afero"
)
func ExampleCopy() {
err := Copy("resources/fixtures/data/example", "resources/test/data.copy/example")
fmt.Println("Error:", err)
info, _ := os.Stat("resources/test/data.copy/example") //nolint: errcheck
fmt.Println("IsDir:", info.IsDir())
// Output:
// Error: <nil>
// IsDir: true
}
func ExampleOptions() {
err := Copy(
"resources/fixtures/data/example",
"resources/test/data.copy/example_with_options",
Options{
Skip: func(_ afero.Fs, src string) (bool, error) {
return strings.HasSuffix(src, ".git-like"), nil
},
OnSymlink: func(afero.Fs, string) SymlinkAction {
return Skip
},
PermissionControl: AddPermission(0o200),
},
)
fmt.Println("Error:", err)
_, err = os.Stat("resources/test/data.copy/example_with_options/.git-like")
fmt.Println("Skipped:", os.IsNotExist(err))
// Output:
// Error: <nil>
// Skipped: true
}