Skip to content

os: Stat on a symlink fails when path has a trailing slash #27225

@AudriusButkevicius

Description

@AudriusButkevicius

What version of Go are you using (go version)?

go version go1.11 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Windows 10 with Developer mode enabled (allowing to create symlinks for unprivileged users)

What did you do?

c:\temp>type test.go
package main

import (
  "os"
  "fmt"
)

func main() {
  fmt.Println(os.Lstat(`c:\temp\b`))
  fmt.Println(os.Lstat(`c:\temp\b\`))
}
c:\temp>mkdir a

c:\temp>mklink /D b a
symbolic link created for b <<===>> a

c:\temp>cmd /c "set GOROOT=c:\go1.10.4&& c:\go1.10.4\bin\go.exe run test.go"
&{b {1040 {477620318 30686378} {477620318 30686378} {477620318 30686378} 0 0} 0 {0 0} c:\temp\b 0 0 0 false} <nil>
&{b {1040 {477620318 30686378} {477620318 30686378} {477620318 30686378} 0 0} 0 {0 0} c:\temp\b\ 0 0 0 false} <nil>

c:\temp>cmd /c "set GOROOT=c:\go&& c:\go\bin\go.exe run test.go"
&{b 1040 {477620318 30686378} {477620318 30686378} {477620318 30686378} 0 0 2684354572 0 {0 0} c:\temp\b 0 0 0 false} <nil>
<nil> FindFirstFile c:\temp\b\: The system cannot find the file specified.

Same issue between Stat and Lstat

What did you expect to see?

Stat to succeed, like it did in Go 1.10.4

What did you see instead?

Stat failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions