当前位置: 首页>>代码示例>>Golang>>正文


Golang DataType.IsObject方法代码示例

本文整理汇总了Golang中github.com/goadesign/goa/design.DataType.IsObject方法的典型用法代码示例。如果您正苦于以下问题:Golang DataType.IsObject方法的具体用法?Golang DataType.IsObject怎么用?Golang DataType.IsObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/goadesign/goa/design.DataType的用法示例。


在下文中一共展示了DataType.IsObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GoTypeRef

// GoTypeRef returns the Go code that refers to the Go type which matches the given data type
// (the part that comes after `var foo`)
// required only applies when referring to a user type that is an object defined inline. In this
// case the type (Object) does not carry the required field information defined in the parent
// (anonymous) attribute.
// tabs is used to properly tabulate the object struct fields and only applies to this case.
// This function assumes the type is in the same package as the code accessing it.
func GoTypeRef(t design.DataType, required []string, tabs int, private bool) string {
	tname := GoTypeName(t, required, tabs, private)
	if t.IsObject() {
		return "*" + tname
	}
	return tname
}
开发者ID:ajoulie,项目名称:goa,代码行数:14,代码来源:types.go

示例2: GoTypeRef

// GoTypeRef returns the Go code that refers to the Go type which matches the given data type
// (the part that comes after `var foo`)
// required only applies when referring to a user type that is an object defined inline. In this
// case the type (Object) does not carry the required field information defined in the parent
// (anonymous) attribute.
// tabs is used to properly tabulate the object struct fields and only applies to this case.
// This function assumes the type is in the same package as the code accessing it.
func GoTypeRef(t design.DataType, required []string, tabs int, private bool) string {
	tname := GoTypeName(t, required, tabs, private)
	if mt, ok := t.(*design.MediaTypeDefinition); ok {
		if mt.IsError() {
			return "error"
		}
	}
	if t.IsObject() {
		return "*" + tname
	}
	return tname
}
开发者ID:konstantin-dzreev,项目名称:goa,代码行数:19,代码来源:types.go

示例3: GoPackageTypeRef

// GoPackageTypeRef returns the Go code that refers to the Go type which matches the given data type.
// versioned indicates whether the type is being referenced from a version package (true) or the
// default package defPkg (false).
// required only applies when referring to a user type that is an object defined inline. In this
// case the type (Object) does not carry the required field information defined in the parent
// (anonymous) attribute.
// tabs is used to properly tabulate the object struct fields and only applies to this case.
func GoPackageTypeRef(t design.DataType, required []string, versioned bool, defPkg string, tabs int) string {
	switch t.(type) {
	case *design.UserTypeDefinition, *design.MediaTypeDefinition:
		var prefix string
		if t.IsObject() {
			prefix = "*"
		}
		return prefix + GoPackageTypeName(t, required, versioned, defPkg, tabs)
	case design.Object:
		return "*" + GoPackageTypeName(t, required, versioned, defPkg, tabs)
	default:
		return GoPackageTypeName(t, required, versioned, defPkg, tabs)
	}
}
开发者ID:RouGang,项目名称:goa,代码行数:21,代码来源:types.go


注:本文中的github.com/goadesign/goa/design.DataType.IsObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。