Fix: file close even if file was not opened (#1417)

Fixed a bug where in many implementations of load-file functions the file-close was still
executed even if the file-open resulted in an error.
This commit is contained in:
EnameEtavir
2021-05-24 23:52:55 +02:00
committed by GitHub
parent 0472cd9996
commit dc453c193d
11 changed files with 11 additions and 11 deletions

View File

@@ -29,10 +29,10 @@ type Gallery struct {
func LoadGalleryFile(filePath string) (*Gallery, error) {
var gallery Gallery
file, err := os.Open(filePath)
defer file.Close()
if err != nil {
return nil, err
}
defer file.Close()
var json = jsoniter.ConfigCompatibleWithStandardLibrary
jsonParser := json.NewDecoder(file)
err = jsonParser.Decode(&gallery)