reorder functions
This commit is contained in:
@@ -48,36 +48,17 @@ func Get(ctx context.Context) (Component, bool) {
|
|||||||
return t, ok
|
return t, ok
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustNew is New but panics on error.
|
// GetFields returns the component as a string map with keys "module" and "path".
|
||||||
func MustNew(ctx context.Context, module string, name string) context.Context {
|
func GetFields(ctx context.Context) (map[string]string, bool) {
|
||||||
if ctx == nil {
|
|
||||||
panic("context is nil")
|
|
||||||
}
|
|
||||||
if module == "" {
|
|
||||||
panic("module cannot be empty")
|
|
||||||
}
|
|
||||||
if name == "" {
|
|
||||||
panic("name cannot be empty")
|
|
||||||
}
|
|
||||||
return insert(ctx, module, name, []string{})
|
|
||||||
}
|
|
||||||
|
|
||||||
// MustExtend is Extend but panics on error.
|
|
||||||
func MustExtend(ctx context.Context, name string) context.Context {
|
|
||||||
if ctx == nil {
|
|
||||||
panic("context is nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
c, ok := Get(ctx)
|
c, ok := Get(ctx)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("missing parent component")
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
if name == "" {
|
return map[string]string{
|
||||||
panic("name cannot be empty")
|
"module": c.Module(),
|
||||||
}
|
"path": c.PathString(),
|
||||||
|
}, true
|
||||||
return insert(ctx, c.Module(), name, c.Path())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New sets a new component on the context, resetting any existing component.
|
// New sets a new component on the context, resetting any existing component.
|
||||||
@@ -112,15 +93,34 @@ func Extend(ctx context.Context, name string) (context.Context, error) {
|
|||||||
return insert(ctx, c.Module(), name, c.Path()), nil
|
return insert(ctx, c.Module(), name, c.Path()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFields returns the component as a string map with keys "module" and "path".
|
// MustNew is New but panics on error.
|
||||||
func GetFields(ctx context.Context) (map[string]string, bool) {
|
func MustNew(ctx context.Context, module string, name string) context.Context {
|
||||||
c, ok := Get(ctx)
|
if ctx == nil {
|
||||||
if !ok {
|
panic("context is nil")
|
||||||
return nil, false
|
}
|
||||||
|
if module == "" {
|
||||||
|
panic("module cannot be empty")
|
||||||
|
}
|
||||||
|
if name == "" {
|
||||||
|
panic("name cannot be empty")
|
||||||
|
}
|
||||||
|
return insert(ctx, module, name, []string{})
|
||||||
}
|
}
|
||||||
|
|
||||||
return map[string]string{
|
// MustExtend is Extend but panics on error.
|
||||||
"module": c.Module(),
|
func MustExtend(ctx context.Context, name string) context.Context {
|
||||||
"path": c.PathString(),
|
if ctx == nil {
|
||||||
}, true
|
panic("context is nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
c, ok := Get(ctx)
|
||||||
|
if !ok {
|
||||||
|
panic("missing parent component")
|
||||||
|
}
|
||||||
|
|
||||||
|
if name == "" {
|
||||||
|
panic("name cannot be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
return insert(ctx, c.Module(), name, c.Path())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user