This commit is contained in:
@@ -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))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user