github.com/micro/go-micro/v2@v2.9.1/registry/service/options.go (about) 1 package service 2 3 import ( 4 "context" 5 6 "github.com/micro/go-micro/v2/client" 7 "github.com/micro/go-micro/v2/registry" 8 ) 9 10 type clientKey struct{} 11 12 // WithClient sets the RPC client 13 func WithClient(c client.Client) registry.Option { 14 return func(o *registry.Options) { 15 if o.Context == nil { 16 o.Context = context.Background() 17 } 18 19 o.Context = context.WithValue(o.Context, clientKey{}, c) 20 } 21 }