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

path: Base is different from file path.Base on windows #71420

Closed
lazysegtree opened this issue Jan 24, 2025 · 4 comments
Closed

path: Base is different from file path.Base on windows #71420

lazysegtree opened this issue Jan 24, 2025 · 4 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. OS-Windows

Comments

@lazysegtree
Copy link

lazysegtree commented Jan 24, 2025

use path/filepath

Originally posted by @seankhliao in #49745

@seankhliao and the rest of golang community. How this issue is closed ?
Sure, we have filepath.Base(), but path.Base() still exists.
Either path.Base() should be fixed with correct implementation for windows, or documentation(https://pkg.go.dev/path#Base) should clearly say that its buggy/deprecated/not platform independent.

I spent half by day today debugging an issue on a windows bug on our app, and eventually found it was due to path.Base() not working as expected.

@qmuntal
Copy link
Member

qmuntal commented Jan 24, 2025

From path's package docs:

Package path implements utility routines for manipulating slash-separated paths.

The path package should only be used for paths separated by forward slashes, such as the paths in URLs. This package does not deal with Windows paths with drive letters or backslashes; to manipulate operating system paths, use the path/filepath package.

IMO the documentation is clear and it already explicitly mentions Windows. What else would you like to see on this docs?

@qmuntal qmuntal added OS-Windows WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jan 24, 2025
@seankhliao seankhliao changed the title Reopening issue - path.Base() does not works in windows path: Base is different from file path.Base on windows Jan 24, 2025
@seankhliao
Copy link
Member

seankhliao commented Jan 24, 2025

As noted above, its behavior is clearly documented to be platform independent which is necessary for safely manipulating non filesystem paths like URLs.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2025
@lazysegtree
Copy link
Author

Ack, my bad.
Instead of reading the path packages overview at the top, I just read the documentation for Base()
Image

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Jan 24, 2025
@qmuntal qmuntal removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. OS-Windows
Projects
None yet
Development

No branches or pull requests

4 participants