I would expect the call above to open the file foo.txt.
If the files are being read from the filesystem (e.g. while in development), the call above works
If the files are read from a package (after having compiled the app), the call above returns a "file not found" error
In both cases,adding a leading slash (assetsBox.Open("/foo.txt")) fixes it. However, this behavior is inconsistent with the fs module in Go, when reading a directory.
Easier to explain if I show the code directly.
Suppose I have a folder
/ui/assets
that contains various files, includingfoo.txt
:I would expect the call above to open the file
foo.txt
.In both cases,adding a leading slash (
assetsBox.Open("/foo.txt")
) fixes it. However, this behavior is inconsistent with thefs
module in Go, when reading a directory.