1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-05 10:20:53 +02:00
go-micro/config/source/cli/options.go
2024-06-04 21:40:43 +01:00

21 lines
365 B
Go

package cli
import (
"context"
"github.com/urfave/cli/v2"
"go-micro.dev/v5/config/source"
)
type contextKey struct{}
// Context sets the cli context.
func Context(c *cli.Context) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, contextKey{}, c)
}
}