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

Function sortedNamedAttributes

codegen/service/service_data.go:1219–1228  ·  view source on GitHub ↗

sortedNamedAttributes returns object fields sorted by attribute name. Union naming uses NameScope uniqueness, so callers that discover unions while traversing objects must use a deterministic field order to avoid oscillating generated identifiers across runs.

(attrs []*expr.NamedAttributeExpr)

Source from the content-addressed store, hash-verified

1217// traversing objects must use a deterministic field order to avoid oscillating
1218// generated identifiers across runs.
1219func sortedNamedAttributes(attrs []*expr.NamedAttributeExpr) []*expr.NamedAttributeExpr {
1220 if len(attrs) < 2 {
1221 return attrs
1222 }
1223 sorted := slices.Clone(attrs)
1224 sort.Slice(sorted, func(i, j int) bool {
1225 return sorted[i].Name < sorted[j].Name
1226 })
1227 return sorted
1228}
1229
1230// primitiveAliasGoType resolves the native Go type for a primitive alias branch.
1231// It uses expr.IsPrimitive to enforce the type contract and then unwraps aliases.

Callers 2

collectUnionTypesFunction · 0.70
collectViewUnionTypesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected