From 0d32d9e8a8784cf3ef39c471b73e502c51085b6d Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 27 Apr 2021 16:55:04 -0700 Subject: [PATCH] os: document that Windows Symlink to missing target creates file symlink Fixes #39183 Change-Id: Iec4a5a561182ade57dc7dc24247710005d6b9f21 Reviewed-on: https://go-review.googlesource.com/c/go/+/314275 Trust: Ian Lance Taylor Reviewed-by: Emmanuel Odeke Run-TryBot: Emmanuel Odeke TryBot-Result: Go Bot --- src/os/file_plan9.go | 2 ++ src/os/file_unix.go | 2 ++ src/os/file_windows.go | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/os/file_plan9.go b/src/os/file_plan9.go index 4f384e9211..604aea607b 100644 --- a/src/os/file_plan9.go +++ b/src/os/file_plan9.go @@ -440,6 +440,8 @@ func Link(oldname, newname string) error { } // Symlink creates newname as a symbolic link to oldname. +// On Windows, a symlink to a non-existent oldname creates a file symlink; +// if oldname is later created as a directory the symlink will not work. // If there is an error, it will be of type *LinkError. func Symlink(oldname, newname string) error { return &LinkError{"symlink", oldname, newname, syscall.EPLAN9} diff --git a/src/os/file_unix.go b/src/os/file_unix.go index deec41324b..a2531b9656 100644 --- a/src/os/file_unix.go +++ b/src/os/file_unix.go @@ -351,6 +351,8 @@ func Link(oldname, newname string) error { } // Symlink creates newname as a symbolic link to oldname. +// On Windows, a symlink to a non-existent oldname creates a file symlink; +// if oldname is later created as a directory the symlink will not work. // If there is an error, it will be of type *LinkError. func Symlink(oldname, newname string) error { e := ignoringEINTR(func() error { diff --git a/src/os/file_windows.go b/src/os/file_windows.go index a2cb96e457..378e2b1c7d 100644 --- a/src/os/file_windows.go +++ b/src/os/file_windows.go @@ -327,6 +327,8 @@ func Link(oldname, newname string) error { } // Symlink creates newname as a symbolic link to oldname. +// On Windows, a symlink to a non-existent oldname creates a file symlink; +// if oldname is later created as a directory the symlink will not work. // If there is an error, it will be of type *LinkError. func Symlink(oldname, newname string) error { // '/' does not work in link's content -- 2.50.0