Fix: WC
All checks were successful
Word Count / count-words (pull_request) Successful in 32s

This commit is contained in:
2026-02-28 00:28:26 +01:00
parent 6fabbec335
commit ee667a1df7

View File

@@ -60,12 +60,7 @@ func main() {
continue continue
} }
count, err := countWordsInFile(content) count := countWords(content)
if err != nil {
fmt.Printf("Error getting review for %s: %v\n", file.Filename, err)
continue
}
counts = append(counts, fmt.Sprintf("#### Review for `%s`\n\n%s", file.Filename, count)) counts = append(counts, fmt.Sprintf("#### Review for `%s`\n\n%s", file.Filename, count))
} }
@@ -97,21 +92,6 @@ func readFile(path string) (string, error) {
return string(content), nil return string(content), nil
} }
func countWordsInFile(path string) (int, error) {
file, err := os.Open(path)
if err != nil {
return 0, err
}
defer file.Close()
content, err := io.ReadAll(file)
if err != nil {
return 0, err
}
return countWords(string(content)), nil
}
func countWords(text string) int { func countWords(text string) int {
return len(strings.Fields(text)) return len(strings.Fields(text))
} }