func (pc *PointerCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
	if !val.CanSet() || val.Kind() != reflect.Ptr {
		return ValueDecoderError{Name: "PointerCodec.DecodeValue", Kinds: []reflect.Kind{reflect.Ptr}, Received: val}
	}

	if vr.Type() == bsontype.Null {
		val.Set(reflect.Zero(val.Type()))
		return vr.ReadNull()
	}

	if val.IsNil() {
		val.Set(reflect.New(val.Type().Elem()))
	}

	pc.l.RLock()
	dec, ok := pc.dcache[val.Type()]
	pc.l.RUnlock()
	if ok {
		if dec == nil {
			return ErrNoDecoder{Type: val.Type()}
		}
		return dec.DecodeValue(dc, vr, val.Elem())
	}

	dec, err := dc.LookupDecoder(val.Type().Elem())
	pc.l.Lock()
	pc.dcache[val.Type()] = dec
	pc.l.Unlock()
	if err != nil {
		return err
	}

	return dec.DecodeValue(dc, vr, val.Elem())
}
// DecodeValue handles decoding a pointer by looking up a decoder for the type it points to and
// using that to decode. If the BSON value is Null, this method will set the pointer to nil.
DecodeValue handles decoding a pointer by looking up a decoder for the type it points to and
using that to decode. If the BSON value is Null, this method will set the pointer to nil.
// DecodeValue handles decoding a pointer by looking up a decoder for the type it points to and // using that to decode . If the BSON value is Null this method will set the pointer to nil .
func (pc *PointerCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
	if !val.CanSet() || val.Kind() != reflect.Ptr {
		return ValueDecoderError{Name: "PointerCodec.DecodeValue", Kinds: []reflect.Kind{reflect.Ptr}, Received: val}
	}
	if vr.Type() == bsontype.Null {
		val.Set(reflect.Zero(val.Type()))
		return vr.ReadNull()
	}
	if val.IsNil() {
		val.Set(reflect.New(val.Type().Elem()))
	}
	pc.l.RLock()
	dec, ok := pc.dcache[val.Type()]
	pc.l.RUnlock()
	if ok {
		if dec == nil {
			return ErrNoDecoder{Type: val.Type()}
		}
		return dec.DecodeValue(dc, vr, val.Elem())
	}
	dec, err := dc.LookupDecoder(val.Type().Elem())
	pc.l.Lock()
	pc.dcache[val.Type()] = dec
	pc.l.Unlock()
	if err != nil {
		return err
	}
	return dec.DecodeValue(dc, vr, val.Elem())
}
func ( pc * PointerCodec ) DecodeValue ( dc DecodeContext , vr bsonrw . ValueReader , val reflect . Value ) error { if ! val . CanSet ( ) || val . Kind ( ) != reflect . Ptr { return ValueDecoderError { Name : " " , Kinds : [ ] reflect . Kind { reflect . Ptr } , Received : val } } if vr . Type ( ) == bsontype . Null { val . Set ( reflect . Zero ( val . Type ( ) ) ) return vr . ReadNull ( ) } if val . IsNil ( ) { val . Set ( reflect . New ( val . Type ( ) . Elem ( ) ) ) } pc . l . RLock ( ) dec , ok := pc . dcache [ val . Type ( ) ] pc . l . RUnlock ( ) if ok { if dec == nil { return ErrNoDecoder { Type : val . Type ( ) } } return dec . DecodeValue ( dc , vr , val . Elem ( ) ) } dec , err := dc . LookupDecoder ( val . Type ( ) . Elem ( ) ) pc . l . Lock ( ) pc . dcache [ val . Type ( ) ] = dec pc . l . Unlock ( ) if err != nil { return err } return dec . DecodeValue ( dc , vr , val . Elem ( ) ) }
DecodeValue handles decoding a pointer by looking up a decoder for the type it points to and
using that to decode.
DecodeValue handles decoding a pointer by looking up a decoder for the type it points to and using that to decode .