path/filepath: Ext does not return correct values #37589
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Consider "path/.config" and ".gitignore". If I use filepath.Ext(path) on either one of those strings I would receive ".config" or ".gitignore".
https://play.golang.org/p/NVteIVi1wTM
This is in my opinion not correct. I opened a PR #37580 but @ianlancetaylor stated it would break compatibility and the function does as documentd. Hence I closed it and opened this issue to start a discussion about it.
An extension for files exists as they provided meta data for operating systems for example to open them with a default application.
A dot file is a hidden file with a normal name. So .gitignore does not have the extension .gitignore the name of the file is gitignore. Similar to hidden folders.
If the file would be .gitignore.go then it would have the .go extension.
In any case filepath.Ext(path) does return an extension for those cases - hidden file, hidden folder- even though they do not have an extension.
A new method could be added which takes that into account or the old gets adjusted. Or maybe my understanding of extensions is just fundamentally wrong.
The text was updated successfully, but these errors were encountered: