github.com/searKing/golang/go@v1.2.117/net/resolver/resolvenow_options.go (about) 1 // Code generated by "go-option -type resolveNow"; 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 ResolveNowOption sets options. 7 type ResolveNowOption interface { 8 apply(*resolveNow) 9 } 10 11 // EmptyResolveNowOption 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 EmptyResolveNowOption struct{} 16 17 func (EmptyResolveNowOption) apply(*resolveNow) {} 18 19 // ResolveNowOptionFunc wraps a function that modifies resolveNow into an 20 // implementation of the ResolveNowOption interface. 21 type ResolveNowOptionFunc func(*resolveNow) 22 23 func (f ResolveNowOptionFunc) apply(do *resolveNow) { 24 f(do) 25 } 26 27 // ApplyOptions call apply() for all options one by one 28 func (o *resolveNow) ApplyOptions(options ...ResolveNowOption) *resolveNow { 29 for _, opt := range options { 30 if opt == nil { 31 continue 32 } 33 opt.apply(o) 34 } 35 return o 36 } 37 38 // sample code for option, default for nothing to change 39 func _ResolveNowOptionWithDefault() ResolveNowOption { 40 return ResolveNowOptionFunc(func(*resolveNow) { 41 // nothing to change 42 }) 43 }