No problem.
HN user
polegone
I linked it in the readme so all those people visiting my project will see yours.
I can't help much myself (you are way ahead of me), but more people should visit your project now.
I tested it by on a several megabyte text file (not that large) and I can see a huge improvement in speed when I use a reader vs. loading the whole thing into memory as I did at first.
I can see now how much of a difference it can make on a really large file, like in the gigabyte range.
BTW, I deleted my earlier comment because the problem I had wasn't anything to do with bufio. I had just made an obvious mistake elsewhere in my code, which I've fixed now.
I am a novice, and that is one of the reasons why I started this project (to learn).
I must say that yours is much more complete than mine, though.
I'm working on that as well. I just fixed cat to crash and log on error, and I'll be fixing the other commands soon.
By the way, I'm wondering how I should go through the file line by line with a reader.
I think the most efficient way may be to scan byte by byte from the start (head) or the end (tail), and count until reaching n amount of newlines (or stop if at the end of the file), then print the bytes between the start/end and the nth newline.
How does this sound?
Thank you. I will look into this.
I'm just doing this for fun and to learn about Go and Unix at the same time.
I am a beginner, and a lot of my code is inefficient and/or incomplete, but by putting it on the Internet I can get criticism and find out where I went wrong.
For instance, some of you have told me that the way I've been reading files is very inefficient, so now I'll try and do it the correct way.