Build a `wc`-style command-line tool in Go. It reads from stdin or one or more file paths, and prints `<lines> <words> <bytes> <name>` for each input plus a total when there's more than one. Ship it as a real Go module with `go.mod`, formatted code, no `go vet` warnings, and a cross-compiled Linux binary committed alongside the source.
bufio.Scanner with bufio.ScanWords for the word count — don't try to roll your own splitter.io.Copy with a counting io.Writer. Don't ReadAll a large file.os.Stdin.Stat() and look at Mode()&os.ModeCharDevice == 0 — that's the canonical way to detect piped input.flag.Parse() for -l (lines only), -w (words only), -c (bytes only) to match real wc. Default is all three.$ echo "hello world\nfoo bar baz" | ./wc-go
2 5 24
$ ./wc-go README.md main.go
18 42 320 README.md
45 98 812 main.go
63 140 1132 total
$ diff <(./wc-go README.md | tr -s ' ') <(wc README.md | tr -s ' ')
(no output — they match)
-m (rune count, multibyte-aware) using utf8.RuneCount. Test on a non-ASCII file.--format json flag that emits {"file": "x", "lines": 1, ...} per file. This sets you up for piping into jq.go install github.com/you/wc-go/cmd/wc@latest works for a teammate.