Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoConfigInContext = errors.New("configuration provider not found in context")
ErrNoConfigInContext is returned when no config is found in the context.
View Source
var RootContext = context.WithValue(context.Background(), ValidContextKey, true)
Functions ¶
func ConfigFromContext ¶
ConfigFromContext returns the configuration provider from the context or an error if no configuration provider is found in the context.
Example ¶
ctx := context.Background()
config, err := configx.New(ctx, []byte(`{"type":"object","properties":{"foo":{"type":"string"}}}`), configx.WithValue("foo", "bar"))
if err != nil {
panic(err)
}
ctx = WithConfig(ctx, config)
fmt.Printf("foo = %s", MustConfigFromContext(ctx).String("foo"))
Output: foo = bar
func IsRootContext ¶
func MustConfigFromContext ¶
MustConfigFromContext returns the configuration provider from the context or panics if no configuration provider is found in the context.
Types ¶
Click to show internal directories.
Click to hide internal directories.