Better HN
topnewbestaskshowjobs
Log inSign up

polegone

178 karma · joined May 8, 2015 (11y ago) · 10 submissions

Submissions

comment 11y ago · link · parent

No problem.

comment 11y ago · link · parent

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.

comment 11y ago · link · parent

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.

comment 11y ago · link · parent

I am a novice, and that is one of the reasons why I started this project (to learn).

comment 11y ago · link · parent

I must say that yours is much more complete than mine, though.

comment 11y ago · link · parent

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?

comment 11y ago · link · parent

Thank you. I will look into this.

comment 11y ago · link · parent

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.

9.

Gonix – Unix tools written in Go(github.com ↗)

148 points · by polegone · 11y ago · 82 comments