Skip to content

Conversation

@dustin-decker
Copy link
Contributor

@dustin-decker dustin-decker commented Nov 20, 2025

Description:

Adds an option to follow symlinks in the fs source.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@dustin-decker dustin-decker requested a review from a team November 20, 2025 18:05
@dustin-decker dustin-decker requested review from a team as code owners November 20, 2025 18:05
Comment on lines 98 to 105
cleanPath := filepath.Clean(path)
fileInfo, err := os.Lstat(cleanPath)
var fileInfo fs.FileInfo
var err error
if s.followSymlinks {
fileInfo, err = os.Stat(cleanPath)
} else {
fileInfo, err = os.Lstat(cleanPath)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: I think this can be simplified via filepath.EvalSymlinks:

cleanPath := filepath.Clean(path)
if s.followSymlinks {
    var err error
    cleanPath, err = filepath.EvalSymlinks(path)
    if err != nil { /* ... */ }
}

}

if fileInfo.Mode()&os.ModeSymlink != 0 {
if !s.followSymlinks && fileInfo.Mode()&os.ModeSymlink != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fileInfo.Mode() would always be non-symlink if os.Stat is used, right? Since Stat follows symlinks.

@dustin-decker dustin-decker requested a review from a team as a code owner November 21, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants