aboutsummaryrefslogtreecommitdiff
path: root/src/os/stat_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/stat_windows.go')
-rw-r--r--src/os/stat_windows.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/os/stat_windows.go b/src/os/stat_windows.go
index 7ac9f7b860..033c3b9353 100644
--- a/src/os/stat_windows.go
+++ b/src/os/stat_windows.go
@@ -123,5 +123,14 @@ func statNolog(name string) (FileInfo, error) {
// lstatNolog implements Lstat for Windows.
func lstatNolog(name string) (FileInfo, error) {
- return stat("Lstat", name, false)
+ followSymlinks := false
+ if name != "" && IsPathSeparator(name[len(name)-1]) {
+ // We try to implement POSIX semantics for Lstat path resolution
+ // (per https://pubs.opengroup.org/onlinepubs/9699919799.2013edition/basedefs/V1_chap04.html#tag_04_12):
+ // symlinks before the last separator in the path must be resolved. Since
+ // the last separator in this case follows the last path element, we should
+ // follow symlinks in the last path element.
+ followSymlinks = true
+ }
+ return stat("Lstat", name, followSymlinks)
}