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

Function sortedNamedAttributes

http/codegen/service_data.go:2861–2870  ·  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

2859// traversing objects must use a deterministic field order to avoid oscillating
2860// generated identifiers across runs.
2861func sortedNamedAttributes(attrs []*expr.NamedAttributeExpr) []*expr.NamedAttributeExpr {
2862 if len(attrs) < 2 {
2863 return attrs
2864 }
2865 sorted := slices.Clone(attrs)
2866 sort.Slice(sorted, func(i, j int) bool {
2867 return sorted[i].Name < sorted[j].Name
2868 })
2869 return sorted
2870}
2871
2872func (sds *ServicesData) attributeTypeData(ut expr.UserType, req, ptr, server bool, rd *ServiceData) *TypeData {
2873 if ut == expr.Empty {

Callers 1

collectHTTPUnionTypesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected