If that "100s of MB" is acceptable to be in memory, then bufio.Scanner with 
properly sized scanner.Buffer is the easiest and battle tested solution.

If not, then you have to reimplement the same, with a temp file as a 
buffer: read input, store in file, seeking to the start on each '\n', 
copying the file to STDOUT when "test" is found.
Not too hard, but have a few edge cases.
Const V a következőt írta (2022. május 7., szombat, 22:40:58 UTC+2):

> I need to write a program that reads STDIN and should output every line 
> that contains a search word "test" to STDOUT. 
>
> How I can test that considering the problem is a line can be 100s of MB 
> long (\n is line end) and tens of MB info is passed to it.
>

-- 
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/0a97a330-cc0a-4919-b05e-64a898ab8392n%40googlegroups.com.

Reply via email to