markbates / pkger

Embed static files in Go binaries (replacement for gobuffalo/packr)
MIT License
1.19k stars 60 forks source link

Leading slash in file name when inside a box #136

Open ItalyPaleAle opened 4 years ago

ItalyPaleAle commented 4 years ago

Easier to explain if I show the code directly.

Suppose I have a folder /ui/assets that contains various files, including foo.txt:

assetsBox, err := pkger.Open("/ui/assets")
if err != nil {
    return err
}
f, err := assetsBox.Open("foo.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 the fs module in Go, when reading a directory.