本文整理匯總了Golang中github.com/raphael/goa/design.AttributeDefinition.AllRequired方法的典型用法代碼示例。如果您正苦於以下問題:Golang AttributeDefinition.AllRequired方法的具體用法?Golang AttributeDefinition.AllRequired怎麽用?Golang AttributeDefinition.AllRequired使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/raphael/goa/design.AttributeDefinition
的用法示例。
在下文中一共展示了AttributeDefinition.AllRequired方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: attributeMarshalerR
// attributeMarshalerR is the recursive implementation of AttributeMarshaler.
func attributeMarshalerR(att *design.AttributeDefinition, context, source, target string, depth int) string {
var marshaler string
switch actual := att.Type.(type) {
case *design.MediaTypeDefinition:
marshaler = mediaTypeMarshalerR(actual, source, target, att.View, depth)
case design.Object:
marshaler = objectMarshalerR(actual, att.AllRequired(), context, source, target, depth)
default:
marshaler = typeMarshalerR(att.Type, context, source, target, depth)
}
validation := ValidationChecker(att, false, source, context, 1)
if validation != "" {
if !strings.HasPrefix(strings.TrimLeft(" \t\n", marshaler), "if err == nil {") {
return fmt.Sprintf(
"%s\n%sif err == nil {\n%s\n%s}",
validation,
Tabs(depth),
marshaler,
Tabs(depth),
)
}
return validation + marshaler
}
return marshaler
}