Thanks to visit codestin.com
Credit goes to github.com

Skip to content

This is an implementation of the wc command line utility in golang

Notifications You must be signed in to change notification settings

ishaan1091/wcgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Your Own WC

This is an implementation of the wc command line utility in golang

How to build

Execute the following command from root of repository -

make build

Running Tests

# 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-html

Test Coverage

Current test coverage:

  • cmd/constants: 100% coverage
  • cmd/utils: 100% coverage
  • cmd/io: 45.5% coverage
  • cmd: 58.3% coverage

Commands


# 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

References

The Secret Life of Text: How Your Keyboard Speaks 100+ Languages

StackOverflow Question Explaining Encoding, Unicode and UTF-8

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Strings, bytes, runes and characters in Go

Understanding Buffered I/O and bufio package in golang

About

This is an implementation of the wc command line utility in golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published