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

Function walkMatches

codegen/go_transform.go:688–698  ·  view source on GitHub ↗

walkMatches iterates through the attributes of source and looks for attributes with identical names in target. walkMatches calls the walker function for each pair of matched attributes. Both source and target must be objects or else walkMatches panics.

(source, target *expr.AttributeExpr, walker func(src, tgt *expr.MappedAttributeExpr, srcc, tgtc *expr.AttributeExpr, n string))

Source from the content-addressed store, hash-verified

686// function for each pair of matched attributes. Both source and target must be
687// objects or else walkMatches panics.
688func walkMatches(source, target *expr.AttributeExpr, walker func(src, tgt *expr.MappedAttributeExpr, srcc, tgtc *expr.AttributeExpr, n string)) {
689 srcMatt := expr.NewMappedAttributeExpr(source)
690 tgtMatt := expr.NewMappedAttributeExpr(target)
691 srcObj := expr.AsObject(srcMatt.Type)
692 tgtObj := expr.AsObject(tgtMatt.Type)
693 for _, nat := range *srcObj {
694 if att := tgtObj.Attribute(nat.Name); att != nil {
695 walker(srcMatt, tgtMatt, nat.Attribute, att, nat.Name)
696 }
697 }
698}
699
700// transformHelperName returns the transformation function name to initialize a
701// target user type from an instance of a source user type.

Callers 3

transformObjectFunction · 0.70
collectHelpersFunction · 0.70

Calls 3

NewMappedAttributeExprFunction · 0.92
AsObjectFunction · 0.92
AttributeMethod · 0.65

Tested by

no test coverage detected