code: func peek(b []byte) (length int, err error) {
  	if len(b) < 1 {
  		return 0, errors.New("invalid encoded key")
  	}
  	flag := b[0]
  	length++
  	b = b[1:]
  	var l int
  	switch flag {
  	case NilFlag:
  	case intFlag, uintFlag, floatFlag, durationFlag:
  		// Those types are stored in 8 bytes.
  		l = 8
  	case bytesFlag:
  		l, err = peekBytes(b, false)
  	case compactBytesFlag:
  		l, err = peekCompactBytes(b)
  	case decimalFlag:
  		l, err = types.DecimalPeak(b)
  	case varintFlag:
  		l, err = peekVarint(b)
  	case uvarintFlag:
  		l, err = peekUvarint(b)
  	default:
  		return 0, errors.Errorf("invalid encoded key flag %v", flag)
  	}
  	if err != nil {
  		return 0, errors.Trace(err)
  	}
  	length += l
  	return
  }
docs: // peeks the first encoded value from b and returns its length.