-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.go
57 lines (46 loc) · 853 Bytes
/
parse.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
46
47
48
49
50
51
52
53
54
55
56
57
package copi
import (
"encoding/json"
"io/ioutil"
"os"
)
// ParseIgnore file
func ParseIgnore(pth string) (map[string]struct{}, error) {
conf := make(map[string]struct{})
if pth == "" {
return conf, nil
}
f, err := os.Open(pth)
if err != nil {
return nil, err
}
defer f.Close()
b, err := ioutil.ReadAll(f)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &conf); err != nil {
return nil, err
}
return conf, nil
}
// ParseTransform file
func ParseTransform(pth string) (map[string]string, error) {
conf := make(map[string]string)
if pth == "" {
return conf, nil
}
f, err := os.Open(pth)
if err != nil {
return nil, err
}
defer f.Close()
b, err := ioutil.ReadAll(f)
if err != nil {
return nil, err
}
if err := json.Unmarshal(b, &conf); err != nil {
return nil, err
}
return conf, nil
}