Write Your Own wc Tool 1st challenge in the Coding Challenges by John Crickett:
While John's site has details on what to do, I want to keep a log on my approach. Link: https://codingchallenges.fyi/challenges/challenge-wc/
IDE - VSCode
- This is alredy installed on my machine at the time of the project.
Language - Go
- I do not know Go but have been wanting to try it out for a long time now.
What should be done?
- Read the number of bytes in a file
- Output the number of bytes in the file
- Add a "-c" CLI option
- Read the input from the CLI ("test.txt")
What did I learn?
- Assignment operator, for loop, packages, opening/closing files in Go
- CLI arguments
- CLI flags
What should be done?
- Add a "-l" CLI option
- Output the number of lines in the file
What did I learn?
- How to use bufio to scan a file line by line
What should be done?
- Add a "-w" CLI option
- Output the number of words in the file
What did I learn?
- ScanWords in bufio can be used to read a file word by word
What should be done?
- Add a "-m" CLI option
- Output the number of characters in the file
What did I learn?
- ScanRunes in bufio can be used to read a file character by character
What should be done?
- Support the default option ("-l", "-w", "-c")
What did I learn?
- Setting the default, no-option version