本文整理匯總了Golang中github.com/raphael/goa/design.APIVersionDefinition.IterateUserTypes方法的典型用法代碼示例。如果您正苦於以下問題:Golang APIVersionDefinition.IterateUserTypes方法的具體用法?Golang APIVersionDefinition.IterateUserTypes怎麽用?Golang APIVersionDefinition.IterateUserTypes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/raphael/goa/design.APIVersionDefinition
的用法示例。
在下文中一共展示了APIVersionDefinition.IterateUserTypes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: generateUserTypes
// generateUserTypes iterates through the user types and generates the data structures and
// marshaling code.
func (g *Generator) generateUserTypes(verdir string, version *design.APIVersionDefinition) error {
utFile := filepath.Join(verdir, "user_types.go")
utWr, err := NewUserTypesWriter(utFile)
if err != nil {
panic(err) // bug
}
title := fmt.Sprintf("%s: Application User Types", version.Context())
imports := []*codegen.ImportSpec{
codegen.SimpleImport("github.com/raphael/goa"),
codegen.SimpleImport("fmt"),
}
utWr.WriteHeader(title, packageName(version), imports)
err = version.IterateUserTypes(func(t *design.UserTypeDefinition) error {
data := &UserTypeTemplateData{
UserType: t,
Versioned: version.Version != "",
DefaultPkg: TargetPackage,
}
return utWr.Execute(data)
})
g.genfiles = append(g.genfiles, utFile)
if err != nil {
return err
}
return utWr.FormatCode()
}