refactor: improve file closing error handling
This commit is contained in:
parent
1b86948c60
commit
373839ee85
1 changed files with 7 additions and 1 deletions
8
main.go
8
main.go
|
@ -26,7 +26,13 @@ func main() {
|
||||||
fmt.Printf("Error opening %s: %v\n", eventPath, err)
|
fmt.Printf("Error opening %s: %v\n", eventPath, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer eventFile.Close()
|
defer func() {
|
||||||
|
closeFileErr := eventFile.Close()
|
||||||
|
if closeFileErr != nil {
|
||||||
|
fmt.Println("Error closing eventFile")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
var event GithubEvent
|
var event GithubEvent
|
||||||
decoder := json.NewDecoder(eventFile)
|
decoder := json.NewDecoder(eventFile)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue