Skip to content

tuanlc/word-count

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published