Closed
Description
What version of Go are you using (go version
)?
$ go version 1.16.2
Does this issue reproduce with the latest release?
Yes
Tested OS
Windows, Linux
What did you do?
//go:embed dir/myfile1.txt dir/myfile2.txt
var embedDir embed.FS
func init() {
entries, _ := embedDir.ReadDir("dir")
for _, entry := range entries {
fmt.Println(embedDir.Name()) // this works
fmt.Println(embedDir.Info()) // this works, too
fmt.Println(embedDir.ReadFile(filepath.Join("dir", entry.Name()))) // this fails on Windows
}
}
This works perfectly okay with Linux as it follows notation of Linux filesystem, but on Windows, even though it can fetch fs.dirEntry
, it cannot read file with error given; open dir/myfile1.txt: file does not exist
.
I can change embed
notation with double backslash \\
and it will work.
//go:embed dir\\myfile1.txt dir\\myfile2.txt
var embedDir embed.FS // now it will work on Windows!!
So I can make that compile only on Windows, but somehow I think this is bug, because it can anyway fetch meta information of file, just cannot open it.
Activity