本文整理汇总了Golang中kego/io/system.UnpackUnknownType函数的典型用法代码示例。如果您正苦于以下问题:Golang UnpackUnknownType函数的具体用法?Golang UnpackUnknownType怎么用?Golang UnpackUnknownType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UnpackUnknownType函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UnpackPageInterface
func UnpackPageInterface(ctx context.Context, in system.Packed) (PageInterface, error) {
switch in.Type() {
case system.J_MAP:
i, err := system.UnpackUnknownType(ctx, in, true, "kego.io/demo/demo2", "page")
if err != nil {
return nil, err
}
ob, ok := i.(PageInterface)
if !ok {
return nil, fmt.Errorf("%T does not implement PageInterface", i)
}
return ob, nil
default:
return nil, fmt.Errorf("Unsupported json type %s when unpacking into PageInterface.", in.Type())
}
}
示例2: UnpackSection
func UnpackSection(ctx context.Context, in system.Packed) (Section, error) {
switch in.Type() {
case system.J_MAP:
i, err := system.UnpackUnknownType(ctx, in, true, "kego.io/demo/site", "section")
if err != nil {
return nil, err
}
ob, ok := i.(Section)
if !ok {
return nil, fmt.Errorf("%T does not implement Section", i)
}
return ob, nil
default:
return nil, fmt.Errorf("Unsupported json type %s when unpacking into Section.", in.Type())
}
}
示例3: UnpackFInterface
func UnpackFInterface(ctx context.Context, in system.Packed) (FInterface, error) {
switch in.Type() {
case system.J_MAP:
i, err := system.UnpackUnknownType(ctx, in, true, "kego.io/process/validate/tests", "f")
if err != nil {
return nil, err
}
ob, ok := i.(FInterface)
if !ok {
return nil, fmt.Errorf("%T does not implement FInterface", i)
}
return ob, nil
default:
return nil, fmt.Errorf("Unsupported json type %s when unpacking into FInterface.", in.Type())
}
}
示例4: UnpackLocalized
func UnpackLocalized(ctx context.Context, in system.Packed) (Localized, error) {
switch in.Type() {
case system.J_MAP:
i, err := system.UnpackUnknownType(ctx, in, true, "kego.io/demo/demo5/translation", "localized")
if err != nil {
return nil, err
}
ob, ok := i.(Localized)
if !ok {
return nil, fmt.Errorf("%T does not implement Localized", i)
}
return ob, nil
default:
return nil, fmt.Errorf("Unsupported json type %s when unpacking into Localized.", in.Type())
}
}