Pull request: all: rm var shadowing, vol. 1

Updates #2803.

Squashed commit of the following:

commit 15fa64ad4fb7561c4b0542245f99869685643bbd
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 11 14:55:28 2021 +0300

    util: imp code

commit c3b0563a44ccc98a5901df19174acdca8a350d62
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 11 14:38:54 2021 +0300

    all: rm var shadowing, vol. 1
This commit is contained in:
Ainar Garipov
2021-03-11 15:38:39 +03:00
parent 94e21e69af
commit 2c9992e0cc
6 changed files with 35 additions and 20 deletions

View File

@@ -337,7 +337,8 @@ func tarGzFileUnpack(tarfile, outdir string) ([]string, error) {
var err2 error
tarReader := tar.NewReader(gzReader)
for {
header, err := tarReader.Next()
var header *tar.Header
header, err = tarReader.Next()
if err == io.EOF {
err2 = nil
break
@@ -377,7 +378,8 @@ func tarGzFileUnpack(tarfile, outdir string) ([]string, error) {
continue
}
f, err := os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(header.Mode&0o777))
var f io.WriteCloser
f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(header.Mode&0o777))
if err != nil {
err2 = fmt.Errorf("os.OpenFile(%s): %w", outputName, err)
break
@@ -449,7 +451,8 @@ func zipFileUnpack(zipfile, outdir string) ([]string, error) {
continue
}
f, err := os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode())
var f io.WriteCloser
f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode())
if err != nil {
err2 = fmt.Errorf("os.OpenFile(): %w", err)
break