word-count

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 6 Imported by: 0

README

Word count CLI in Go

MIT license Project CI Go Report Card Go.Dev reference

Motivation

https://codingchallenges.fyi/challenges/challenge-wc

Commands

Development
  • Run unit test
$ make test
  • Run build
$ make build
  • Clean folder
$ make clean
Usage
Directly usage

After building the tool successfully, there will be the executable file ccwc in the root folder.

  • Count bytes
$ ./ccwc -c test.txt
342190 test.txt
  • Count lines
$ ./ccwc -l test.txt
7145 test.txt
  • Count words
$ ./ccwc -w test.txt
58164 test.txt
  • Count characters
$ ./ccwc -m test.txt
339292 test.txt
  • Count characters
$ ./ccwc test.txt
7145 58164 342190 test.txt
Read from standar input
  • Count bytes
$ cat test.txt | ./ccwc -c
342190 test.txt
  • Count lines
$ cat test.txt | ./ccwc -l
7145 test.txt
  • Count words
$ cat test.txt | ./ccwc -w
58164 test.txt
  • Count characters
$ cat test.txt | ./ccwc -m
339292 test.txt
  • Count characters
$ cat test.txt | ./ccwc
7145 58164 342190 test.txt

Testing

ccwc is a tool that tries to clone features from the Unix command wc. Thus, the unit tests will use the output from wc as the source of truth. Moreover, the outcome of count words method could be different on different environments.

License

MIT

Copyright (c) 2024-present, Tuan LE CONG

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL