io/fs: provide backwards-compatible migration path from ioutil.ReadFile to fs.ReadFile #44286
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Hi there, I'm enjoying the go1.16 RC, I'm trying to migrate some code from using ioutil.ReadFile to fs.ReadFile while staying backwards-compatible. I'm running into two things:
ioutil.ReadFile("./path/to/file.txt")
work withos.DirFS(".")
, because it rejects the leading./
I can get around those things by doing something like this:
Which is technically an invalid implementation, although it's not entirely clear why those restrictions are in place. It would be nice if something like the above
osFS
was built-in, so there's a clear migration path fromioutil.ReadFile
tofs.ReadFile
.What version of Go are you using (
go version
)?The text was updated successfully, but these errors were encountered: