- scanner := bufio.NewScanner(strings.NewReader(input))
- for scanner.Scan() {
- // We parse one line at a time, to save effort if we only need
- // the first few lines.
- ch <- parseManifestLine(scanner.Text())
+ // This slice holds the current line and the remainder of the
+ // manifest. We parse one line at a time, to save effort if we
+ // only need the first few lines.
+ lines := []string{"", input}
+ for {
+ lines = strings.SplitN(lines[1], "\n", 2)
+ if len(lines[0]) > 0 {
+ // Only parse non-blank lines
+ ch <- parseManifestStream(lines[0])
+ }
+ if len(lines) == 1 {
+ break
+ }