code: func (s *Stream) Kind() (kind Kind, size uint64, err error) {
  	var tos *listpos
  	if len(s.stack) > 0 {
  		tos = &s.stack[len(s.stack)-1]
  	}
  	if s.kind < 0 {
  		s.kinderr = nil
  		// Don't read further if we're at the end of the
  		// innermost list.
  		if tos != nil && tos.pos == tos.size {
  			return 0, 0, EOL
  		}
  		s.kind, s.size, s.kinderr = s.readKind()
  		if s.kinderr == nil {
  			if tos == nil {
  				// At toplevel, check that the value is smaller
  				// than the remaining input length.
  				if s.limited && s.size > s.remaining {
  					s.kinderr = ErrValueTooLarge
  				}
  			} else {
  				// Inside a list, check that the value doesn't overflow the list.
  				if s.size > tos.size-tos.pos {
  					s.kinderr = ErrElemTooLarge
  				}
  			}
  		}
  	}
  	// Note: this might return a sticky error generated
  	// by an earlier call to readKind.
  	return s.kind, s.size, s.kinderr
  }
docs: // Kind returns the kind and size of the next value in the
  // input stream.
  //
  // The returned size is the number of bytes that make up the value.
  // For kind == Byte, the size is zero because the value is
  // contained in the type tag.
  //
  // The first call to Kind will read size information from the input
  // reader and leave it positioned at the start of the actual bytes of
  // the value. Subsequent calls to Kind (until the value is decoded)
  // will not advance the input reader and return cached information.