4 ms·
I don't think Go gives you freedom, actually. There aren't any good standard library functions for dealing with badly encoded unicode for file names, for exampl
by jeroenhd 5y ago
I don't think Go gives you freedom, actually. There aren't any good standard library functions for dealing with badly encoded unicode for file names, for example.
Instead, Go provides what the language designers considered solutions to most problems. Window not having Unix permissions? Just fake a bunch of them. Path not valid unicode? Probably not a problem. As long ad you agree with the way the Go designers think, that'll save you tons of work.
Just don't use Go in situations where those solutions might not work out, like when you're iterating over arbitrary files instead of the files you've created yourself in Go code.
- shadowgovt 5y agoThe counterpoint is "your filenames shouldn't be badly-encoded unicode." In other words, "If `ls` can't render it, it's a bad filename. Rename the file." (This does mean that Go is constraining the set of problems it's easy to solve with it. But that's the nature of programming in general... We decide what problems need to be easier to solve at the expense of putting some problems outside the "sweet spot" and requiring more work to solve them).
- WJW 5y agoIf `ls` can't render a filename that is legal under the POSIX specs, there are two possibilities: - `ls` is wrong and should be fixed. - The specs are wrong and should not allow filenames to be arbitrary bytesequences. The third option ("The user is wrong even though they did exactly what was in the spec") is just unsatisfactory because it self-contradicts.
- shadowgovt 5y agoSpecs are a three-edged sword: the spec, the intent, and the implementation. And "The user is wrong even though they did exactly what was in the spec" is pretty much the rule, not the exception.