code: func (b *BufReader) ReadSlice(delim byte) (line []byte, err error) {
  	for {
  		// Search buffer.
  		if i := bytes.IndexByte(b.Bytes(), delim); i >= 0 {
  			i++
  			line = b.buf[b.r : b.r+i]
  			b.r += i
  			b.changeAvailable(-i)
  			break
  		}
  
  		// Pending error?
  		if b.err != nil {
  			line = b.flush()
  			err = b.readErr()
  			break
  		}
  
  		buffered := b.Buffered()
  
  		// Out of available.
  		if b.available != -1 && buffered >= b.available {
  			line = b.flush()
  			err = io.EOF
  			break
  		}
  
  		// Buffer full?
  		if buffered >= len(b.buf) {
  			line = b.flush()
  			err = bufio.ErrBufferFull
  			break
  		}
  
  		b.fill() // buffer is not full
  	}
  
  	// Handle last byte, if any.
  	if i := len(line) - 1; i >= 0 {
  		b.lastByte = int(line[i])
  	}
  
  	return line, err
  }
docs: // ReadSlice reads until the first occurrence of delim in the input,
  // returning a slice pointing at the bytes in the buffer.
  // The bytes stop being valid at the next read.
  // If ReadSlice encounters an error before finding a delimiter,
  // it returns all the data in the buffer and the error itself (often io.EOF).
  // ReadSlice fails with error ErrBufferFull if the buffer fills without a delim.
  // Because the data returned from ReadSlice will be overwritten
  // by the next I/O operation, most clients should use
  // ReadBytes or ReadString instead.
  // ReadSlice returns err != nil if and only if line does not end in delim.