The question is will scanner.Scan handle a line of 100s MB? On Saturday, May 7, 2022 at 2:49:08 PM UTC-7 Amnon wrote:
> How about something like > > func grep(pat []byte, r io.Reader, w io.Writer) error { > scanner := bufio.NewScanner(r) > for scanner.Scan() { > if (bytes.Contains(scanner.Bytes(), pat)) { > w.Write(scanner.Bytes()) > } > } > > return scanner.Err() > } > > and for extra speed, just allocate a bigger buffer to the scanner... > On Saturday, 7 May 2022 at 21:46:33 UTC+1 Jan Mercl wrote: > >> On Sat, May 7, 2022 at 10:24 PM Constantine Vassilev <ths...@gmail.com> >> wrote: >> >> > I need to write a program that reads STDIN and should output every line >> that contains a search word "test" to STDOUT. >> >> Piping the data through grep(1) would be my first option. >> > -- 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/75ea906e-d371-44e1-81fe-f4f5f0435cadn%40googlegroups.com.