-
Notifications
You must be signed in to change notification settings - Fork 1k
Suggestion: Check case of configuration filenames to avoid cross-platform incompatibilities #1035
Comments
@sdboyer Can I work on this? If yes, can you point me in the right direction wrt where I would have to make the changes? |
@sudo-suhas yes, absolutely! 🎉 🎉 the key place to look will be in as for doing the check itself, you'll probably want to take inspiration from that should be enough to get you started - please let me know what other pointers would be helpful! |
@sdboyer I took a look at the functions you pointed to. However, I think the problem here is slightly different. What I need to do is check if the package main
import (
"fmt"
"os"
)
func main() {
fileStat, err := os.Stat("./test.txt")
if err != nil {
panic(err)
}
fmt.Println(fileStat.Name())
}
The only way to print the exact case of the file that I have been able to figure out is to use package main
import (
"fmt"
"os"
"path/filepath"
)
func main() {
dirname := "." + string(filepath.Separator)
d, err := os.Open(dirname)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer d.Close()
files, err := d.Readdir(-1)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println("Reading " + dirname)
for _, file := range files {
if file.Mode().IsRegular() {
if filepath.Ext(file.Name()) == ".txt" {
fmt.Println(file.Name())
}
}
}
}
However this is quite wasteful. Is there any better way to do this? |
there is not, AFAIK. that's why i was loathe to recommend it, and just suggested the crappier approach of trying the one case variation. you're right, of course, that we have to try all the combinations if we actually want to truly enforce this as a rule. the best i can offer is that you can at least avoid having to |
Following discussion on Reddit, I think it might be a good idea if
dep
checked the case of the names of its configuration files such asGopkg.toml
, at least on Mac.This would prevent the problem of Mac users checking in a project with
gopkg.toml
in lower case, which works on the Mac (because it's case-insensitive) but fails on Linux.The text was updated successfully, but these errors were encountered: