On Sat, 2022-05-07 at 16:16 -0700, Const V wrote:
> The question is will scanner.Scan handle a line of 100s MB?

No, at least not by default (https://pkg.go.dev/bufio#Scanner.Buffer).
But that that point you want to start questioning why you're doing what
you're doing.

Your invocation of grep can be a lot simpler

```
func grep(match string, r io.Reader, stdout, stderr io.Writer) error {
        cmd := exec.Command("fgrep", match)
        cmd.Stdin = r
        cmd.Stdout = stdout
        cmd.Stderr = stderr
        return cmd.Run()
}
```

You can then do whatever you want with the buffered output and stderr.
You can also make this use a pipe with minor changes if you expect the
output to be long and that stream processing of that would be sensible
(use cmd.Start instead of Run and look into StdoutPipe).


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/407bcc70f772fa7e7980469c2098c8b8b481ecf1.camel%40kortschak.io.

Reply via email to