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

Method Find

expr/attribute.go:588–615  ·  view source on GitHub ↗

Find finds a child attribute with the given name in the attribute and its bases and references. If the parent attribute is not an object, it returns nil.

(name string)

Source from the content-addressed store, hash-verified

586// its bases and references. If the parent attribute is not an object, it
587// returns nil.
588func (a *AttributeExpr) Find(name string) *AttributeExpr {
589 findAttrFn := func(typ DataType) *AttributeExpr {
590 switch t := typ.(type) {
591 case UserType:
592 return t.Attribute().Find(name)
593 case *Object:
594 if att := t.Attribute(name); att != nil {
595 return att
596 }
597 }
598 return nil
599 }
600
601 if att := findAttrFn(a.Type); att != nil {
602 return att
603 }
604 for _, b := range a.Bases {
605 if att := findAttrFn(b); att != nil {
606 return att
607 }
608 }
609 for _, ref := range a.References {
610 if att := findAttrFn(ref); att != nil {
611 return att
612 }
613 }
614 return nil
615}
616
617// Delete removes an attribute with the given name. It does nothing if the
618// attribute expression is not an object type.

Callers 15

ValidateMethod · 0.95
AttributeFunction · 0.95
OneOfFunction · 0.95
findKeyFunction · 0.80
validateMessageFunction · 0.80
validateMetadataFunction · 0.80
ValidateMethod · 0.80
FinalizeMethod · 0.80
PathParamsMethod · 0.80
PrepareMethod · 0.80
ValidateMethod · 0.80
FinalizeMethod · 0.80

Calls 1

AttributeMethod · 0.65

Tested by 4

TestProjectFunction · 0.64
TestCookieAPIKeySecurityFunction · 0.64
TestGoTransformUnionFunction · 0.64