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

Method IsPrimitivePointer

expr/attribute.go:477–492  ·  view source on GitHub ↗

IsPrimitivePointer returns true if the field generated for the given attribute should be a pointer to a primitive type. The receiver attribute must be an object. If useDefault is true and the attribute has a default value then IsPrimitivePointer returns false. This makes it possible to differentiat

(attName string, useDefault bool)

Source from the content-addressed store, hash-verified

475// No True True
476// No False True
477func (a *AttributeExpr) IsPrimitivePointer(attName string, useDefault bool) bool {
478 o := AsObject(a.Type)
479 if o == nil {
480 panic("checking pointer field on non-object") // bug
481 }
482 att := o.Attribute(attName)
483 if att == nil {
484 return false
485 }
486 if !IsPrimitive(att.Type) {
487 return false
488 }
489 t := unalias(att.Type)
490 return t.Kind() != BytesKind && t.Kind() != AnyKind &&
491 !a.IsRequired(attName) && (!a.HasDefaultValue(attName) || !useDefault)
492}
493
494func unalias(dt DataType) DataType {
495 if ut, ok := dt.(UserType); ok {

Callers 11

goTypeDefFunction · 0.45
analyzeMethod · 0.45
buildResponsesMethod · 0.45
extractPathParamsMethod · 0.45
extractQueryParamsMethod · 0.45
extractHeadersMethod · 0.45
extractCookiesMethod · 0.45
initSSEDataFunction · 0.45
transformObjectFunction · 0.45
extractMetadataFunction · 0.45

Calls 7

IsRequiredMethod · 0.95
HasDefaultValueMethod · 0.95
AsObjectFunction · 0.85
IsPrimitiveFunction · 0.85
unaliasFunction · 0.70
AttributeMethod · 0.65
KindMethod · 0.65

Tested by 1