This is an implementation of the wc command line utility in golang
Execute the following command from root of repository -
make build
# Run all tests
make test
# Run tests with verbose output
make test-verbose
# Run tests with coverage
make test-coverage
# Generate HTML coverage report
make test-coverage-htmlCurrent test coverage:
cmd/constants: 100% coveragecmd/utils: 100% coveragecmd/io: 45.5% coveragecmd: 58.3% coverage
# Output number of bytes in file
> <PATH_TO_REPO>/bin/wcgo -c test.txt
342190 test.txt
# Output number of lines in file
> <PATH_TO_REPO>/bin/wcgo -l test.txt
7145 test.txt
# Output number of words in file
> <PATH_TO_REPO>/bin/wcgo -w test.txt
58164 test.txt
# Output number of characters in file
> <PATH_TO_REPO>/bin/wcgo -m test.txt
339292 test.txt
# Use pipe operator to pass input and run multiple commands at same time
> cat test.txt | <PATH_TO_REPO>/bin/wcgo -lcw
1 52801 327900
# Run command on default params without invoking any flag
> <PATH_TO_REPO>/bin/wcgo test.txt
7145 58164 342190 test.txt
The Secret Life of Text: How Your Keyboard Speaks 100+ Languages
StackOverflow Question Explaining Encoding, Unicode and UTF-8