github.com/searKing/golang/go@v1.2.117/net/resolver/resolveoneaddr_options.go (about)

     1  // Code generated by "go-option -type resolveOneAddr"; 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 ResolveOneAddrOption sets options.
     7  type ResolveOneAddrOption interface {
     8  	apply(*resolveOneAddr)
     9  }
    10  
    11  // EmptyResolveOneAddrOption 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 EmptyResolveOneAddrOption struct{}
    16  
    17  func (EmptyResolveOneAddrOption) apply(*resolveOneAddr) {}
    18  
    19  // ResolveOneAddrOptionFunc wraps a function that modifies resolveOneAddr into an
    20  // implementation of the ResolveOneAddrOption interface.
    21  type ResolveOneAddrOptionFunc func(*resolveOneAddr)
    22  
    23  func (f ResolveOneAddrOptionFunc) apply(do *resolveOneAddr) {
    24  	f(do)
    25  }
    26  
    27  // ApplyOptions call apply() for all options one by one
    28  func (o *resolveOneAddr) ApplyOptions(options ...ResolveOneAddrOption) *resolveOneAddr {
    29  	for _, opt := range options {
    30  		if opt == nil {
    31  			continue
    32  		}
    33  		opt.apply(o)
    34  	}
    35  	return o
    36  }
    37  
    38  // WithresolveOneAddrPicker appends Picker in resolveOneAddr.
    39  func WithresolveOneAddrPicker(v ...PickOption) ResolveOneAddrOption {
    40  	return ResolveOneAddrOptionFunc(func(o *resolveOneAddr) {
    41  		o.Picker = append(o.Picker, v...)
    42  	})
    43  }
    44  
    45  // WithresolveOneAddrPickerReplace sets Picker in resolveOneAddr.
    46  func WithresolveOneAddrPickerReplace(v ...PickOption) ResolveOneAddrOption {
    47  	return ResolveOneAddrOptionFunc(func(o *resolveOneAddr) {
    48  		o.Picker = v
    49  	})
    50  }