diff --git a/yq.go b/yq.go index 2aa87c04..d41d311b 100644 --- a/yq.go +++ b/yq.go @@ -46,12 +46,18 @@ func MoveFile(sourcePath, destPath string) error { } outputFile, err := os.Create(destPath) if err != nil { - inputFile.Close() + err = inputFile.Close() + if err != nil { + return fmt.Errorf("Failed close original file: %s", err) + } return fmt.Errorf("couldn't open dest file: %s", err) } defer outputFile.Close() _, err = io.Copy(outputFile, inputFile) - inputFile.Close() + err = inputFile.Close() + if err != nil { + return fmt.Errorf("Failed close original file: %s", err) + } if err != nil { return fmt.Errorf("writing to output file failed: %s", err) }