本文整理匯總了Golang中zombiezen/com/go/capnproto2/std/capnp/schema.Type.Interface方法的典型用法代碼示例。如果您正苦於以下問題:Golang Type.Interface方法的具體用法?Golang Type.Interface怎麽用?Golang Type.Interface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類zombiezen/com/go/capnproto2/std/capnp/schema.Type
的用法示例。
在下文中一共展示了Type.Interface方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: makeTypeRef
func makeTypeRef(t schema.Type, rel *node, nodes nodeMap) (typeRef, error) {
nodeRef := func(id uint64) (typeRef, error) {
ni, err := nodes.mustFind(id)
if err != nil {
return typeRef{}, err
}
return makeNodeTypeRef(ni, rel)
}
if ref, ok := staticTypeRefs[t.Which()]; ok {
return ref, nil
}
switch t.Which() {
case schema.Type_Which_enum:
return nodeRef(t.Enum().TypeId())
case schema.Type_Which_structType:
return nodeRef(t.StructType().TypeId())
case schema.Type_Which_interface:
return nodeRef(t.Interface().TypeId())
case schema.Type_Which_list:
lt, _ := t.List().ElementType()
if ref, ok := staticListTypeRefs[lt.Which()]; ok {
return ref, nil
}
switch lt.Which() {
case schema.Type_Which_enum:
ref, err := nodeRef(lt.Enum().TypeId())
if err != nil {
return ref, err
}
ref.name = ref.name + "_List"
ref.newfunc = "New" + ref.name
return ref, nil
case schema.Type_Which_structType:
ref, err := nodeRef(lt.StructType().TypeId())
if err != nil {
return ref, err
}
ref.name = ref.name + "_List"
ref.newfunc = "New" + ref.name
return ref, nil
case schema.Type_Which_anyPointer, schema.Type_Which_list, schema.Type_Which_interface:
return typeRef{name: "PointerList", newfunc: "NewPointerList", imp: capnpImportSpec}, nil
}
}
return typeRef{}, fmt.Errorf("unable to reference type %v", t.Which())
}