-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add path separator constants and utility function. #6
base: main
Are you sure you want to change the base?
Conversation
Define constants for `path_separator_{unix,windows}` and add `path_separator()` utility function getting the right one for the platform currently being run on.
2ba5254
to
1c590a6
Compare
1c590a6
to
3cc0bf0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello! What's the motivator for this change? Thank you.
It's useful for people who find themselves needing to join paths for a different system (e.g. if you're on Unix and want to compose a Windows UNC share path to send to a remote Windows system). It's also useful to know what path separator the current system you're running on is using if you need to manipulate paths directly. Go has one FWIW: https://pkg.go.dev/path/filepath#pkg-constants |
In Gleam we don't like to have multiple ways to do the same thing. Given we have functions for both splitting and joining paths wouldn't this be duplication? |
There is currently no way to join a Windows path with this package without relying on something else transparently translating the slashes into backslashes for you (which most Windows syscalls fortunately transparenty do, but it's better to be safe than sorry). This package should at the very least be changed so that:
Both of the above points were beyond the scope of my original patch (#5) and I intended on adding them later with the help of these constants/function, but I got side-tracked with the issues with I can make these separator constants/function private and convert this PR to include the above changes if you wish. |
Duplicate APIs are not an option so it sounds like the solution is to make the join function use |
Includes separate commit with minor docstring formatting changes