GeertJohan / go.rice

go.rice is a Go package that makes working with resources such as html,js,css,images,templates, etc very easy.
BSD 2-Clause "Simplified" License
2.42k stars 186 forks source link

Implement io.Writer for File #129

Open mattes opened 5 years ago

mattes commented 5 years ago

It would be nice if type File would implement io.Writer. That way I could update some static files on the fly when served via http.FileServer(box.HTTPBox()).

GeertJohan commented 5 years ago

So, writing to the file would completely overwrite? Or would it append? I'm not sure if this is something rice should do itself; or if it would be something for a layer in between http.FileServer and box.HTTPBox().

It would probably be cleaner to implement a separate package that provides a http.FileSystem by wrapping an existing http.FileSystem (e.g. box.HTTPBox()), but allows for modifications/overwrites. It first checks its local changeset, if there's no matching file, then forwards the Open(..) call to the wrapped http.FileSystem.

GeertJohan commented 5 years ago

Probably interesting to look at for this: https://github.com/spf13/afero