Skip to content

Commit

Permalink
fix the error when providing a file name
Browse files Browse the repository at this point in the history
  • Loading branch information
lazygyu committed Dec 9, 2022
1 parent 009e6bb commit c3a401c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@ func main() {
filename := args[0]

// open file
f, err := os.Open(filename)
fd, err := os.Open(filename)
if err != nil {
log.Fatal("cannot open the file")
}
defer f.Close()
fStat, err := fd.Stat()
if err != nil || fStat.Size() == 0 {
log.Fatal("Invalid file")
}
defer fd.Close()
f = bufio.NewReader(fd)
}

// load img
Expand Down

0 comments on commit c3a401c

Please sign in to comment.