github.com/searKing/golang/go@v1.2.117/net/resolver/build_options.go (about) 1 // Code generated by "go-option -type Build"; DO NOT EDIT. 2 // Install go-option by "go get install github.com/searKing/golang/tools/go-option" 3 4 package resolver 5 6 // A BuildOption sets options. 7 type BuildOption interface { 8 apply(*Build) 9 } 10 11 // EmptyBuildOption does not alter the configuration. It can be embedded 12 // in another structure to build custom options. 13 // 14 // This API is EXPERIMENTAL. 15 type EmptyBuildOption struct{} 16 17 func (EmptyBuildOption) apply(*Build) {} 18 19 // BuildOptionFunc wraps a function that modifies Build into an 20 // implementation of the BuildOption interface. 21 type BuildOptionFunc func(*Build) 22 23 func (f BuildOptionFunc) apply(do *Build) { 24 f(do) 25 } 26 27 // ApplyOptions call apply() for all options one by one 28 func (o *Build) ApplyOptions(options ...BuildOption) *Build { 29 for _, opt := range options { 30 if opt == nil { 31 continue 32 } 33 opt.apply(o) 34 } 35 return o 36 } 37 38 // WithBuildClientConn sets ClientConn in Build. 39 func WithBuildClientConn(v ClientConn) BuildOption { 40 return BuildOptionFunc(func(o *Build) { 41 o.ClientConn = v 42 }) 43 }