-
Notifications
You must be signed in to change notification settings - Fork 6
/
util.go
40 lines (34 loc) · 1010 Bytes
/
util.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
package generator
import (
"path/filepath"
"github.com/dyweb/gommon/util/fsutil"
)
func DefaultIgnores() *fsutil.Ignores {
return fsutil.NewIgnores(
[]fsutil.IgnorePattern{
fsutil.ExactPattern(".git"),
fsutil.ExactPattern("testdata"),
fsutil.ExactPattern("vendor"),
fsutil.ExactPattern(".idea"),
fsutil.ExactPattern(".vscode"),
},
nil,
)
}
// WriteFile writes file using permission 0664
// NOTE: 0664 is octal literal in Go, the code would compile for 664, but the result file mode is incorrect
// learned this the hard way https://github.com/dyweb/gommon/issues/41
// stat -c %a pkg.go
// NOTE: this code is now in
//func WriteFile(f string, b []byte) error {
// if err := ioutil.WriteFile(f, b, 0664); err != nil {
// return errors.WithStack(err)
// }
// return nil
//}
func join(s ...string) string {
return filepath.Join(s...)
}
func Header(generator string, template string) string {
return "// Code generated by " + generator + " from " + template + " DO NOT EDIT.\n"
}