github.com/searKing/golang/go@v1.2.117/net/resolver/resolveaddr_options.go (about) 1 // Code generated by "go-option -type resolveAddr"; 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 ResolveAddrOption sets options. 7 type ResolveAddrOption interface { 8 apply(*resolveAddr) 9 } 10 11 // EmptyResolveAddrOption 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 EmptyResolveAddrOption struct{} 16 17 func (EmptyResolveAddrOption) apply(*resolveAddr) {} 18 19 // ResolveAddrOptionFunc wraps a function that modifies resolveAddr into an 20 // implementation of the ResolveAddrOption interface. 21 type ResolveAddrOptionFunc func(*resolveAddr) 22 23 func (f ResolveAddrOptionFunc) apply(do *resolveAddr) { 24 f(do) 25 } 26 27 // ApplyOptions call apply() for all options one by one 28 func (o *resolveAddr) ApplyOptions(options ...ResolveAddrOption) *resolveAddr { 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 _ResolveAddrOptionWithDefault() ResolveAddrOption { 40 return ResolveAddrOptionFunc(func(*resolveAddr) { 41 // nothing to change 42 }) 43 }