-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
75 lines (63 loc) · 1.12 KB
/
types.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
import (
"go/token"
"strings"
)
var (
skipStructComment = []string{"fmgen:-", "fmgen:skip", "fmgen:exclude"}
)
type genField struct {
name string
typ string
optional bool
skip bool
ptr bool
array bool
}
type genComment struct {
lineNum int
value string
}
type genStruct struct {
name string
lineNum int
fields []genField
comment *genComment
}
func (g genStruct) Skip() bool {
// check comment for skip directive
if g.comment != nil {
for _, c := range skipStructComment {
if strings.Contains(strings.ToLower(g.comment.value), c) {
return true
}
}
}
// check flags for struct includes
if *flagStructs == "" {
return false
}
skip := true
structSplit := strings.Split(*flagStructs, ",")
for _, s := range structSplit {
if strings.TrimSpace(s) == g.name {
skip = false
}
}
return skip
}
type genPackage struct {
dirname string
pkg string
fset *token.FileSet
structs []genStruct
imports []string
}
type genFile struct {
dirname string
filename string
pkg string
fset *token.FileSet
structs []genStruct
imports []string
}