code: func breakStream(reader io.ReadSeeker, max int, callback func(chunk []byte) error) error {
  
  	var buf []byte = make([]byte, max+1)
  	var writeAt int
  	for {
  		n, err := reader.Read(buf[writeAt:max])
  		if n == 0 && err == io.EOF {
  			break
  		}
  
  		// If last line does not end with LF, add one for it
  		if err == io.EOF && buf[writeAt+n-1] != '\n' {
  			n++
  			buf[writeAt+n-1] = '\n'
  		}
  
  		data := buf[0 : writeAt+n]
  
  		// Cut after the last LF character
  		cut := bytes.LastIndexByte(data, '\n') + 1
  		if cut == 0 {
  			// This line is too long, but just let it break here
  			cut = len(data)
  		}
  		if err := callback(buf[:cut]); err != nil {
  			return err
  		}
  
  		writeAt = copy(buf, data[cut:])
  
  		if err != nil && err != io.EOF {
  			return err
  		}
  	}
  
  	if writeAt != 0 {
  		return callback(buf[:writeAt])
  	}
  
  	return nil
  }
docs: // breakStream breaks text from reader into chunks, with every chunk less than max.
  // Unless a single line is longer than max, it always cut at end of lines ("\n")