code: func makeOptionalPtrDecoder(typ reflect.Type) (decoder, error) {
  	etype := typ.Elem()
  	etypeinfo, err := cachedTypeInfo1(etype, tags{})
  	if err != nil {
  		return nil, err
  	}
  	dec := func(s *Stream, val reflect.Value) (err error) {
  		kind, size, err := s.Kind()
  		if err != nil || size == 0 && kind != Byte {
  			// rearm s.Kind. This is important because the input
  			// position must advance to the next value even though
  			// we don't read anything.
  			s.kind = -1
  			// set the pointer to nil.
  			val.Set(reflect.Zero(typ))
  			return err
  		}
  		newval := val
  		if val.IsNil() {
  			newval = reflect.New(etype)
  		}
  		if err = etypeinfo.decoder(s, newval.Elem()); err == nil {
  			val.Set(newval)
  		}
  		return err
  	}
  	return dec, nil
  }
docs: // makeOptionalPtrDecoder creates a decoder that decodes empty values
  // as nil. Non-empty values are decoded into a value of the element type,
  // just like makePtrDecoder does.
  //
  // This decoder is used for pointer-typed struct fields with struct tag "nil".