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

Function needInit

http/codegen/service_data.go:3059–3083  ·  view source on GitHub ↗

needInit returns true if and only if the given type is or makes use of user types.

(dt expr.DataType)

Source from the content-addressed store, hash-verified

3057// needInit returns true if and only if the given type is or makes use of user
3058// types.
3059func needInit(dt expr.DataType) bool {
3060 if dt == expr.Empty {
3061 return false
3062 }
3063 switch actual := dt.(type) {
3064 case expr.Primitive:
3065 return false
3066 case *expr.Array:
3067 return needInit(actual.ElemType.Type)
3068 case *expr.Map:
3069 return needInit(actual.KeyType.Type) ||
3070 needInit(actual.ElemType.Type)
3071 case *expr.Object:
3072 for _, nat := range *actual {
3073 if needInit(nat.Attribute.Type) {
3074 return true
3075 }
3076 }
3077 return false
3078 case expr.UserType:
3079 return true
3080 default:
3081 panic(fmt.Sprintf("unknown data type %T", actual)) // bug
3082 }
3083}
3084
3085// upgradeParams returns the data required to render the websocket_upgrade
3086// template.

Callers 6

buildPayloadDataMethod · 0.85
buildResponsesMethod · 0.85
buildErrorsDataMethod · 0.85
buildRequestBodyTypeMethod · 0.85
buildResponseBodyTypeMethod · 0.85
initWebSocketDataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected