JohnCrickett / goccwc

Go solution to Coding Challenges wc

Home Page:https://codingchallenges.fyi/challenges/challenge-wc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

goccwc

Go solution to Coding Challenges first challenge: build your own wc tool

Testing

Step 1

goccwc % wc -c test.txt
  342190 test.txt
goccwc % go run . -c test.txt
342190  test.txt

Step 2

goccwc % wc -l test.txt
    7145 test.txt
goccwc % go run . -l test.txt
7145    test.txt

Step 3

% wc -w test.txt
   58164 test.txt
goccwc % go run . -w test.txt
58164   test.txt

With the addition of some unit tests, which can be run with:

goccwc % go test .
ok      ccwc

Step 4

goccwc % wc -m test.txt
  339292 test.txt
goccwc % go run . -m test.txt
339292  test.txt

Step 5

% wc test.txt
    7145   58164  342190 test.txt
goccwc % go run . test.txt
7145    58164   342190  test.txt

Step 6 (Final Step)

goccwc % cat test.txt | wc -l
    7145
goccwc % cat test.txt | go run . -l
7145

Testing on Big Files (Over 100 GB)

goccwc % seq 1 300000 | xargs -Inone cat test.txt | wc
 2143500000 17449200000 102657000000
goccwc % seq 1 300000 | xargs -Inone cat test.txt | go run .
2143500000      17449200000     102657000000

Both use < 3MB memory.

About

Go solution to Coding Challenges wc

https://codingchallenges.fyi/challenges/challenge-wc/

License:MIT License


Languages

Language:Go 97.8%Language:Makefile 2.2%