nit: shorter defer body

This commit is contained in:
Motiejus Jakštys 2021-08-29 18:39:43 +03:00 committed by Motiejus Jakštys
parent cca579d218
commit f02af98ac5

View File

@ -153,9 +153,8 @@ func Flatten(rd io.ReadSeeker, w io.Writer, opts ...Option) (_err error) {
defer func() {
// Avoiding use of multierr: if error is present, return
// that. Otherwise return whatever `Close` returns.
err1 := tw.Close()
if _err == nil {
_err = err1
if err := tw.Close(); err != nil && _err == nil {
_err = err
}
}()
// iterate through all layers, all files, and write files.