-
Notifications
You must be signed in to change notification settings - Fork 12
/
build_options.go
43 lines (35 loc) · 1.03 KB
/
build_options.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
// Code generated by "go-option -type Build"; DO NOT EDIT.
// Install go-option by "go get install github.com/searKing/golang/tools/go-option"
package resolver
// A BuildOption sets options.
type BuildOption interface {
apply(*Build)
}
// EmptyBuildOption does not alter the configuration. It can be embedded
// in another structure to build custom options.
//
// This API is EXPERIMENTAL.
type EmptyBuildOption struct{}
func (EmptyBuildOption) apply(*Build) {}
// BuildOptionFunc wraps a function that modifies Build into an
// implementation of the BuildOption interface.
type BuildOptionFunc func(*Build)
func (f BuildOptionFunc) apply(do *Build) {
f(do)
}
// ApplyOptions call apply() for all options one by one
func (o *Build) ApplyOptions(options ...BuildOption) *Build {
for _, opt := range options {
if opt == nil {
continue
}
opt.apply(o)
}
return o
}
// WithBuildClientConn sets ClientConn in Build.
func WithBuildClientConn(v ClientConn) BuildOption {
return BuildOptionFunc(func(o *Build) {
o.ClientConn = v
})
}