https://github.com/johncrickett/goccwc
Go solution to Coding Challenges wc
https://github.com/johncrickett/goccwc
challenges coding coding-challenges
Last synced: 9 months ago
JSON representation
Go solution to Coding Challenges wc
- Host: GitHub
- URL: https://github.com/johncrickett/goccwc
- Owner: JohnCrickett
- License: mit
- Created: 2023-11-20T09:57:26.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-19T22:07:12.000Z (10 months ago)
- Last Synced: 2025-03-27T13:51:18.363Z (10 months ago)
- Topics: challenges, coding, coding-challenges
- Language: Go
- Homepage: https://codingchallenges.fyi/challenges/challenge-wc/
- Size: 143 KB
- Stars: 33
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goccwc
Go solution to [Coding Challenges](https://codingchallenges.fyi/challenges/intro) first challenge: [build your own wc tool](https://codingchallenges.fyi/challenges/challenge-wc)
## Testing
### Step 1
```bash
goccwc % wc -c test.txt
342190 test.txt
goccwc % go run . -c test.txt
342190 test.txt
```
### Step 2
```bash
goccwc % wc -l test.txt
7145 test.txt
goccwc % go run . -l test.txt
7145 test.txt
```
### Step 3
```bash
% 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:
```bash
goccwc % go test .
ok ccwc
```
### Step 4
```bash
goccwc % wc -m test.txt
339292 test.txt
goccwc % go run . -m test.txt
339292 test.txt
```
### Step 5
```bash
% wc test.txt
7145 58164 342190 test.txt
goccwc % go run . test.txt
7145 58164 342190 test.txt
```
### Step 6 (Final Step)
```bash
goccwc % cat test.txt | wc -l
7145
goccwc % cat test.txt | go run . -l
7145
```
### Testing on Big Files (Over 100 GB)
```bash
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.