From 88a8a2705684e693082cabaec18b76615cf0b4f0 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 27 Apr 2021 13:51:45 +0200 Subject: [PATCH] os: don't check non-nil err twice in Symlink on windows Change-Id: I398d324723025b559fdca783fc334de9be68f2d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/314030 Trust: Tobias Klauser Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot --- src/os/file_windows.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/os/file_windows.go b/src/os/file_windows.go index 0d3c048a759..a2cb96e4573 100644 --- a/src/os/file_windows.go +++ b/src/os/file_windows.go @@ -365,17 +365,14 @@ func Symlink(oldname, newname string) error { flags |= syscall.SYMBOLIC_LINK_FLAG_DIRECTORY } err = syscall.CreateSymbolicLink(n, o, flags) - if err != nil { // the unprivileged create flag is unsupported // below Windows 10 (1703, v10.0.14972). retry without it. flags &^= windows.SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE - err = syscall.CreateSymbolicLink(n, o, flags) - } - - if err != nil { - return &LinkError{"symlink", oldname, newname, err} + if err != nil { + return &LinkError{"symlink", oldname, newname, err} + } } return nil }