You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, http.File.Readdir in golang returns direct child files, so gives [test.txt, folder1/]
However, when I pack the files, File.Readdir seems to perform a recursive directory listing, and returns [test.txt,folder1,test2.txt] Note that test2.txt behaves as if it were in the root folder.
This causes issues in code using Readdir to recursively copy a directory from an embedded filesystem, and causes http.FileServer to give an incorrect listing when served without index.html
Suppose the following folder structure:
By default,
http.File.Readdir
in golang returns direct child files, so gives[test.txt, folder1/]
However, when I pack the files,
File.Readdir
seems to perform a recursive directory listing, and returns[test.txt,folder1,test2.txt]
Note thattest2.txt
behaves as if it were in the root folder.This causes issues in code using Readdir to recursively copy a directory from an embedded filesystem, and causes
http.FileServer
to give an incorrect listing when served withoutindex.html
This issue is caused by https://github.com/rakyll/statik/blob/master/fs/fs.go#L163 , which does not check whether the file is in a subpath.
On a related note, empty directories are not listed at all, meaning that it would seem like they are non-existent.
The text was updated successfully, but these errors were encountered: