func (b *ByteBuf) SetWriterIndex(newWriterIndex int) error {
	if newWriterIndex < b.readerIndex || newWriterIndex > b.Capacity() {
		return io.ErrShortBuffer
	}
	b.writerIndex = newWriterIndex
	return nil
}
SetWriterIndex set the write index
package goetty
import (
	"errors"
	"io"
)
func ReadN(r io.Reader, n int) ([]byte, error) {
	data := make([]byte, n)
	_, err := r.Read(data)
	if err != nil {
		return nil, err
	}
	return data, nil
}
func ReadInt(r io.Reader) (int, error) {
	data, err := ReadN(r, 4)
	if err != nil {
		return 0, err
	}
	return Byte2Int(data), nil
}
func Byte2Int(data []byte) int {
	return int((int(data[0])&0xff)<<24 | (int(data[1])&0xff)<<16 | (int(data[2])&0xff)<<8 | (int(data[3]) & 0xff))
}
func Byte2Int64(data []byte) int64 {
	return int64((int64(data[0])&0xff)<<56 | (int64(data[1])&0xff)<<48 | (int64(data[2])&0xff)<<40 | (int64(data[3])&0xff)<<32 | (int64(data[4])&0xff)<<24 | (int64(data[5])&0xff)<<16 | (int64(data[6])&0xff)<<8 | (int64(data[7]) & 0xff))
}
func Int2BytesTo(v int, ret []byte) {
	ret[0] = byte(v >> 24)
	ret[1] = byte(v >> 16)
	ret[2] = byte(v >> 8)
	ret[3] = byte(v)
}
func Int2Bytes(v int) []byte {
	ret := make([]byte, 4)
	Int2BytesTo(v, ret)
	return ret
}
func Int64ToBytesTo(v int64, ret []byte) {
	ret[0] = byte(v >> 56)
	ret[1] = byte(v >> 48)
	ret[2] = byte(v >> 40)
	ret[3] = byte(v >> 32)
	ret[4] = byte(v >> 24)
	ret[5] = byte(v >> 16)
	ret[6] = byte(v >> 8)
	ret[7] = byte(v)
}
func Int64ToBytes(v int64) []byte {
	ret := make([]byte, 8)
	Int64ToBytesTo(v, ret)
	return ret
}
type ByteBuf struct {
	capacity    int
	pool        Pool
	buf         []byte  
	readerIndex int     
	writerIndex int     
	markedIndex int
}
var ErrTooLarge = errors.New("goetty.ByteBuf: too large")
func NewByteBuf(capacity int) *ByteBuf {
	return NewByteBufPool(capacity, getDefaultMP())
}
func NewByteBufPool(capacity int, pool Pool) *ByteBuf {
	return &ByteBuf{
		capacity:    capacity,
		buf:         pool.Alloc(capacity),
		readerIndex: 0,
		writerIndex: 0,
		pool:        pool,
	}
}
func (b *ByteBuf) RawBuf() []byte {
	return b.buf
}
func (b *ByteBuf) Clear() {
	b.readerIndex = 0
	b.writerIndex = 0
}
func (b *ByteBuf) Release() {
	b.pool.Free(b.buf)
	b.buf = nil
}
func (b *ByteBuf) Resume(capacity int) {
	b.buf = b.pool.Alloc(b.capacity)
}
func (b *ByteBuf) Capacity() int {
	return len(b.buf)  
}
func (b *ByteBuf) SetReaderIndex(newReaderIndex int) error {
	if newReaderIndex < 0 || newReaderIndex > b.writerIndex {
		return io.ErrShortBuffer
	}
	b.readerIndex = newReaderIndex
	return nil
}
func (b *ByteBuf) GetReaderIndex() int {
	return b.readerIndex
}
func (b *ByteBuf) GetWriteIndex() int {
	return b.writerIndex
}
func (b *ByteBuf) GetMarkerIndex() int {
	return b.markedIndex
}
func (b *ByteBuf) GetMarkedRemind() int {
	return b.markedIndex - b.readerIndex
}
func (b *ByteBuf) GetMarkedRemindData() []byte {
	return b.buf[b.readerIndex:b.markedIndex]
}