MCPcopy Create free account
hub / github.com/goadesign/goa / GoTypeDef

Method GoTypeDef

codegen/scope.go:125–133  ·  view source on GitHub ↗

GoTypeDef returns the Go code that defines a Go type which matches the data structure definition (the part that comes after `type foo`). ptr if true indicates that the attribute must be stored in a pointer (except array and map types which are always non-pointers) useDefault if true indicates that

(att *expr.AttributeExpr, ptr, useDefault bool)

Source from the content-addressed store, hash-verified

123// useDefault if true indicates that the attribute must not be a pointer
124// if it has a default value.
125func (s *NameScope) GoTypeDef(att *expr.AttributeExpr, ptr, useDefault bool) string {
126 pkg := ""
127 if loc := UserTypeLocation(att.Type); loc != nil {
128 pkg = loc.PackageName()
129 } else if p, ok := att.Meta.Last("struct:pkg:path"); ok && p != "" {
130 pkg = Goify(filepath.Base(p), false)
131 }
132 return s.goTypeDef(att, ptr, useDefault, pkg)
133}
134
135// GoTypeDefWithTargetPkg returns the Go type definition string, qualifying any
136// user types inside inline structs with the provided target package. This helps

Callers 9

TestGoTypeDefFunction · 0.95
GoFullTypeNameMethod · 0.95
protoBufGoFullTypeNameFunction · 0.80
collectTypesFunction · 0.80
buildMethodDataMethod · 0.80
initStreamDataMethod · 0.80
buildProjectedTypeFunction · 0.80
buildViewedResultTypeFunction · 0.80

Calls 5

goTypeDefMethod · 0.95
UserTypeLocationFunction · 0.85
GoifyFunction · 0.85
PackageNameMethod · 0.80
LastMethod · 0.80

Tested by 1

TestGoTypeDefFunction · 0.76