Skip to content

Latest commit

 

History

History
70 lines (58 loc) · 1.24 KB

README.md

File metadata and controls

70 lines (58 loc) · 1.24 KB

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.