Description
What version of Go are you using (go version
)?
go version go1.10 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
GOOS=windows GOARCH=amd64
What did you do?
Tried to use os.Stat on "nul": os.Stat("nul")
What did you expect to see?
A valid FileInfo with no error, as is the case with: os.Stat("NUL")
.
What did you see instead?
An os.PathError
error.
Additional
Other os
operations, such as os.Create
, succeed with either "nul" or "NUL".
Windows will discard any data written to any variation of the filename "NUL", not just uppercase.
os/stat_windows.go
checks against OS.DevNull
which is a constant "NUL"
.
if name == DevNull {
return &devNullStat, nil
}
Something like this (with or without the short-circuit) would resolve this.
if len(name) == len(DevNul) && strings.ToUpper(name) == DevNull {
return &devNullStat, nil
}
However, I don't know if introducing the strings
dependency into the Windows os
pkg is reasonable.
If it is I can submit a PR for this. The only other thing I can think of is duplicating the functionality of ToUpper
into /os/internal/
to handle this.