// Write implements the io.Writer interface.
//
// Write buffers data until it hits a newline, at which point it checks if the
// buffered data is a URL. If it is, it writes that URL to the MessageWriter
// instance it was created with, along with the prefix prepended.
Write implements the io.Writer interface.

Write buffers data until it hits a newline, at which point it checks if the
buffered data is a URL. If it is, it writes that URL to the MessageWriter
instance it was created with, along with the prefix prepended.
// Write implements the io . Writer interface . // // Write buffers data until it hits a newline at which point it checks if the // buffered data is a URL . If it is it writes that URL to the MessageWriter // instance it was created with along with the prefix prepended .
func (uw *URLWriter) Write(data []byte) (int, error) {
	start := 0
	for i, b := range data {
		if b == byte('\n') {
			uw.buffer.Write(data[start:i])
			uw.commit()
			start = i + 1
		}
	}
	uw.buffer.Write(data[start:])
	return len(data), nil
}
func ( uw * URLWriter ) Write ( data [ ] byte ) ( int , error ) { start := 0 for i , b := range data { if b == byte ( '\n' ) { uw . buffer . Write ( data [ start : i ] ) uw . commit ( ) start = i + 1 } } uw . buffer . Write ( data [ start : ] ) return len ( data ) , nil }
Write implements the io.Writer interface.
Write implements the io . Writer interface .
// If we hit a newline, copy data[start:i] into the buffer and commit