-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder.go
59 lines (41 loc) · 919 Bytes
/
builder.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
package mengpo
var _ = New
type builder struct {
options *options
}
func New() *builder {
return &builder{
options: newDefaultOptions(),
}
}
func (b *builder) Tag(tag string) *builder {
b.options.tag = tag
return b
}
func (b *builder) Initialize(initialize bool) *builder {
b.options.initialize = initialize
return b
}
func (b *builder) PanicOnError() *builder {
b.options.errorMod = errorModPanic
return b
}
func (b *builder) ReturnOnError() *builder {
b.options.errorMod = errorModReturn
return b
}
func (b *builder) SilentOnError() *builder {
b.options.errorMod = errorModSilent
return b
}
func (b *builder) Getter(getter getter) *builder {
b.options.getter = getter
return b
}
func (b *builder) Processor(processor processor) *builder {
b.options.processors = append(b.options.processors, processor)
return b
}
func (b *builder) Build() *mengpo {
return newMengpo(b.options)
}