1package config23import "context"45// ContextKey is the context key for the config.6var ContextKey = struct{ string }{"config"}78// WithContext returns a new context with the configuration attached.9func WithContext(ctx context.Context, cfg *Config) context.Context {10 return context.WithValue(ctx, ContextKey, cfg)11}1213// FromContext returns the configuration from the context.14func FromContext(ctx context.Context) *Config {15 if c, ok := ctx.Value(ContextKey).(*Config); ok {16 return c17 }1819 return nil20}