1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-04-23 11:07:43 +02:00
2021-10-12 12:55:53 +01:00

21 lines
398 B
Go

package runtimevar
import (
"context"
"go-micro.dev/v4/config/source"
"gocloud.dev/runtimevar"
)
type variableKey struct{}
// WithVariable sets the runtimevar.Variable.
func WithVariable(v *runtimevar.Variable) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, variableKey{}, v)
}
}