You can try to use mmap. Store in memory the start and end/size of a line, so that when a line contains your word, you can pass the address directly to libc.write, using cgo. In alternative, you can create a slice backed by the mapped memory using https://pkg.go.dev/reflect#SliceHeader.
Not tested. Manlio On Saturday, May 7, 2022 at 10:40:58 PM UTC+2 Const V wrote: > 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/25bd7405-f08d-4e8e-a2b3-cceb366da7a1n%40googlegroups.com.