34 lines
564 B
Go
34 lines
564 B
Go
//go:build !solution
|
|
|
|
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func LinesCountInFile(lines map[string]int, filename string) {
|
|
file, err := os.Open(filename)
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer file.Close()
|
|
scanner := bufio.NewScanner(file)
|
|
for scanner.Scan() {
|
|
line := scanner.Text()
|
|
lines[line]++
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
filenames, lines := os.Args[1:], make(map[string]int)
|
|
for _, filename := range filenames {
|
|
LinesCountInFile(lines, filename)
|
|
}
|
|
for line, count := range lines {
|
|
if count != 1 {
|
|
fmt.Printf("%v\t%v\n", count, line)
|
|
}
|
|
}
|
|
}
|