Skip to content

path/filepath: WalkDir does not treat "." as equivalent to os.Getwd() #50804

Closed as not planned
@bcmills

Description

@bcmills

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

go1.18-16d6a5233a

Does this issue reproduce with the latest release?

Yes.

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

linux/amd64 via play.golang.org.

What did you do?

(https://go.dev/play/p/OLEED5lI02l?v=gotip)

With PWD set to a path ending in a symlink to the actual working directory, compare the behavior of filepath.WalkDir with "." and with the directory reported by os.Getwd().

What did you expect to see?

Equivalent behavior for "." and os.Getwd(). Specifically, I expected filepath.WalkDir to report the current working directory as a symlink in both cases.

What did you see instead?

os.Chdir accepts the symlink as valid and changes to the underlying directory. With a matching PWD environment variable, os.Getwd() reports the symlink as the current working directory (as intended since #8400).

filepath.WalkDir(cwd, …) treats the current directory as the symlink itself, and does not list its contents.

However, filepath.WalkDir(".", …) treats "." as the underlying directory and walks its contents.

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.Unfortunate

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions