|
Larry Clapp |
at Nov 6, 2012 at 3:00 pm
|
⇧ |
| |
Just to make sure: You know you could either just pipe find into your Go
program:
find / | your_go_program
or open a pipe from find in your Go program (http://golang.org/pkg/os/#Pipe)
directly, right?
No mmap required.
To answer your question, in the buffer package there are functions that
allow you to read directly from the buffer using regular Read calls.
As for newlines -> zero bytes: find -print0. See also the find manpage for
other printing options, e.g. -printf or -fprintf or -fprint0.
-- L
On Monday, November 5, 2012 4:56:58 PM UTC-5, Lukáš Zapletal wrote:
Hello,
I would like to map file created with
find / >the_file
(text file, each line one entry) into memory with golang and then iterate
through it. For memory mapping there is
func Mmap(fd int, offset int64, length int, prot int, flags int) (data
[]byte, err error)
which returns byte slice, now, to read a line I plan to reach byte by
byte. Is there more effective approach?
Is there something if I would replace newlines in the file with zero bytes?
Thanks
--