func parseBinaryStream(r io.Reader) <-chan streamItem {
	itemChannel := make(chan streamItem)

	go func() {
		// First four bytes of the stream must be the version marker.
		if err := verifyByteVersionMarker(r); err != nil {
			itemChannel <- streamItem{Error: err}
			return
		}

		var values []Value
		for {
			switch val, err := parseNextBinaryValue(nil, r); {
			case err == io.EOF:
				itemChannel <- streamItem{Digest: &Digest{values: values}}
				// Signal that there isn't any more data coming.
				close(itemChannel)
				return
			case err != nil:
				itemChannel <- streamItem{Error: err}
				return
			case val != nil:
				values = append(values, val)
			default:
				itemChannel <- streamItem{Digest: &Digest{values: values}}
				values = nil
			}
		}
	}()

	return itemChannel
}
// parseBinaryStream reads from the given reader until either an error
// is encountered or the reader returns (0, io.EOF), at which point
// the returned channel is closed.  If an error occurred then the error
// is sent on the channel before it is closed.  Reading from the stream
// is not buffered.
parseBinaryStream reads from the given reader until either an error
is encountered or the reader returns (0, io.EOF), at which point
the returned channel is closed.  If an error occurred then the error
is sent on the channel before it is closed.  Reading from the stream
is not buffered.
// parseBinaryStream reads from the given reader until either an error // is encountered or the reader returns ( 0 io . EOF ) at which point // the returned channel is closed . If an error occurred then the error // is sent on the channel before it is closed . Reading from the stream // is not buffered .
func parseBinaryStream(r io.Reader) <-chan streamItem {
	itemChannel := make(chan streamItem)
	go func() {
		if err := verifyByteVersionMarker(r); err != nil {
			itemChannel <- streamItem{Error: err}
			return
		}
		var values []Value
		for {
			switch val, err := parseNextBinaryValue(nil, r); {
			case err == io.EOF:
				itemChannel <- streamItem{Digest: &Digest{values: values}}
				close(itemChannel)
				return
			case err != nil:
				itemChannel <- streamItem{Error: err}
				return
			case val != nil:
				values = append(values, val)
			default:
				itemChannel <- streamItem{Digest: &Digest{values: values}}
				values = nil
			}
		}
	}()
	return itemChannel
}
func parseBinaryStream ( r io . Reader ) <- chan streamItem { itemChannel := make ( chan streamItem ) go func ( ) { if err := verifyByteVersionMarker ( r ) ; err != nil { itemChannel <- streamItem { Error : err } return } var values [ ] Value for { switch val , err := parseNextBinaryValue ( nil , r ) ; { case err == io . EOF : itemChannel <- streamItem { Digest : & Digest { values : values } } close ( itemChannel ) return case err != nil : itemChannel <- streamItem { Error : err } return case val != nil : values = append ( values , val ) default : itemChannel <- streamItem { Digest : & Digest { values : values } } values = nil } } } ( ) return itemChannel }
parseBinaryStream reads from the given reader until either an error
is encountered or the reader returns (0, io.EOF), at which point
the returned channel is closed.
parseBinaryStream reads from the given reader until either an error is encountered or the reader returns ( 0 io . EOF ) at which point the returned channel is closed .
// First four bytes of the stream must be the version marker. // Signal that there isn't any more data coming.