From bad05321a0a4d37c4a9d649f19d4ab85a515f797 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Mon, 20 Mar 2023 11:08:46 +0100 Subject: [PATCH] go: remove redefinitions of builtins Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- csi/test/mount_integration_test.go | 4 ++-- internal/installer/installer.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/csi/test/mount_integration_test.go b/csi/test/mount_integration_test.go index 0841c72ab..051c97c8c 100644 --- a/csi/test/mount_integration_test.go +++ b/csi/test/mount_integration_test.go @@ -34,7 +34,7 @@ func teardown(devicePath string) { _ = exec.Command("/bin/rm", "-f", devicePath).Run() } -func copy(source, target string) error { +func cp(source, target string) error { return exec.Command("cp", source, target).Run() } @@ -142,7 +142,7 @@ func TestDeviceCloning(t *testing.T) { _, err := mapper.OpenCryptDevice(context.Background(), DevicePath, DeviceName, false) assert.NoError(err) - require.NoError(copy(DevicePath, DevicePath+"-copy")) + require.NoError(cp(DevicePath, DevicePath+"-copy")) defer teardown(DevicePath + "-copy") _, err = mapper.OpenCryptDevice(context.Background(), DevicePath+"-copy", DeviceName+"-copy", false) diff --git a/internal/installer/installer.go b/internal/installer/installer.go index 9ea5f6673..9f01ec966 100644 --- a/internal/installer/installer.go +++ b/internal/installer/installer.go @@ -223,17 +223,17 @@ func (i *OsInstaller) copy(oldname, newname string, perm fs.FileMode) (err error if err := i.fs.MkdirAll(path.Dir(newname), fs.ModePerm); err != nil { return fmt.Errorf("copying %q to %q: unable to create destination folder: %w", oldname, newname, err) } - new, openNewErr := i.fs.OpenFile(newname, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, perm) + newFile, openNewErr := i.fs.OpenFile(newname, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, perm) if openNewErr != nil { return fmt.Errorf("copying %q to %q: cannot open destination file for writing: %w", oldname, newname, openNewErr) } defer func() { - _ = new.Close() + _ = newFile.Close() if err != nil { _ = i.fs.Remove(newname) } }() - if _, err := io.Copy(new, old); err != nil { + if _, err := io.Copy(newFile, old); err != nil { return fmt.Errorf("copying %q to %q: copying file contents: %w", oldname, newname, err) }