github.com/aacfactory/avro@v1.2.12/internal/base/schema_ptr.go (about) 1 package base 2 3 import ( 4 "fmt" 5 "github.com/modern-go/reflect2" 6 "reflect" 7 ) 8 9 func parsePtrType(typ reflect2.Type) (s Schema, err error) { 10 if typ.Implements(marshalerType) || typ.Implements(unmarshalerType) { 11 return NewPrimitiveSchema(Raw, nil), nil 12 } 13 ptrType := typ.(reflect2.PtrType) 14 elemType := ptrType.Elem() 15 if elemType.Kind() != reflect.Struct { 16 err = fmt.Errorf("avro: parse %s failed, only support ptr struct", typ.String()) 17 return 18 } 19 elem, elemErr := parseStructType(elemType) 20 if elemErr != nil { 21 err = elemErr 22 return 23 } 24 s, err = NewUnionSchema([]Schema{&NullSchema{}, elem}) 25 return 26 }