New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
embed: unable to access embed openFile Seek method #44175
Comments
The intent is that you write the code to work with any file system, perhaps like this: func serveFile(name string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
file, err := static.Open(name)
if err != nil {
http.Error(w, "file not found", http.StatusNotFound)
return
}
defer file.Close()
st, err := file.Stat()
if err != nil {
http.Error(w, err.Error(), http.StatusForbidden)
return
}
http.ServeContent(w, r, name, st.ModTime(), file.(io.ReadSeeker))
}
} |
I can confirm this resolves my issue. |
Does this work with the renderer? I'm getting: looking at this line here and wondering if it works with the embedded FS impl: https://github.com/lafriks/go-tiled/blob/master/render/renderer.go#L89 |
What version of Go are you using (
go version
)?go version go1.16rc1 linux/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
The file to be served.
What did you see instead?
Extra
embed.openFile implements io.ReadSeeker:
https://github.com/golang/go/blob/master/src/embed/embed.go#L357
but we return fs.File interface when opening a file:
https://github.com/golang/go/blob/master/src/embed/embed.go#L295
and the openFile type is not public:
https://github.com/golang/go/blob/master/src/embed/embed.go#L337
My opinion is openFile type should be public and we should return it instead of fs.FS
Edit: On second thought, I think the openFile and openDir types being public would be enough
The text was updated successfully, but these errors were encountered: