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

Commit

Permalink
Merge pull request #59 from testwill/close
Browse files Browse the repository at this point in the history
fix: check returned error before deferring file.Close()
  • Loading branch information
jweny authored Oct 30, 2023
2 parents fa5ef34 + c6c415f commit 269099d
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 269099d

Please sign in to comment.