A simple implementation of the Unix wc (word count) utility written in Go.
gowc counts bytes, words, lines, and finds the longest line length in text files — similar to the standard wc command.
./main [-c] [-w] [-l] [-L] file [file ...]
| Flag | Description |
|---|---|
-c |
Print the byte count |
-w |
Print the word count |
-l |
Print the line count |
-L |
Print the longest line length |
If no flag is specified, all counts are displayed.
go build -o main main.go$ ./main test.txt
Filepath: test.txt
-----------------------------
Byte Count : 327854
Word Count : 58164
Line Count : 7144
Longest Line Length : 78
$ ./main -c test.txt
Filepath: test.txt
-----------------------------
Byte Count : 327854
$ ./main -w test.txt
Filepath: test.txt
-----------------------------
Word Count : 58164
$ ./main -l test.txt
Filepath: test.txt
-----------------------------
Line Count : 7144
$ ./main -L test.txt
Filepath: test.txt
-----------------------------
Longest Line Length : 78
$ cat test.txt | ./main -w
Word Count : 58164