Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
fix: check returned error before deferring file.Close()
Browse files Browse the repository at this point in the history
  • Loading branch information
testwill committed Oct 12, 2023
1 parent fa5ef34 commit c6c415f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
func ReadingLines(filename string) []string {
var result []string
file, err := os.Open(filename)
defer file.Close()
if err != nil {
return result
}
defer file.Close()

scanner := bufio.NewScanner(file)
for scanner.Scan() {
Expand Down

0 comments on commit c6c415f

Please sign in to comment.