Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace OS-specific path separators with forward-slashes (as per io/fs) #1025

Open
2 tasks
radeksimko opened this issue Aug 2, 2022 · 0 comments
Open
2 tasks
Labels
enhancement New feature or request technical-debt

Comments

@radeksimko
Copy link
Member

Background

Currently all logic relating to filesystem works with OS-specific path separators - i.e. in practice \ on Windows and / everywhere else. In order for us to fully utilise io/fs package and its functions, we need to align our separators with the expectations of that package.

This means using / (forward slashes) exclusively (even on Windows) as path separators. This also makes it more straight-forward to test any FS-dependent logic using testing/fstest which also makes the same assumptions about path separator being /.

https://pkg.go.dev/io/fs#ValidPath

Note that paths are slash-separated on all systems, even Windows. Paths containing other characters such as backslash and colon are accepted as valid, but those characters must never be interpreted by an FS implementation as path element separators.

Proposal

  • Use universal /-separated paths in the following packages (which currently import path/filepath):
    • internal/filesystem
    • internal/pathcmp
    • internal/terraform/datadir
    • internal/uri
    • internal/document
    • internal/lsp
    • internal/terraform/parser
    • internal/logging
    • internal/langserver/diagnostics
    • internal/langserver/handlers (initialize + workspace/didChangeWatchedFiles handlers + test files)
    • internal/walker
  • Update internal/state to accept document.DirHandle instead of paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request technical-debt
Projects
None yet
Development

No branches or pull requests

1 participant