all repos — homestead @ 65039b065ba634b9c4b4c7f4b42ebccdbfd40ce0

Code for my website

remove buffers in file writer

Alan Pearce
commit

65039b065ba634b9c4b4c7f4b42ebccdbfd40ce0

parent

f7d8beffaa09ecf863996d29c72f508eb3952c84

1 file changed, 13 insertions(+), 0 deletions(-)

changed files
M domain/web/templates/files.godomain/web/templates/files.go
@@ -1,14 +1,27 @@
package templates import ( + "io" "io/fs" "os" "alin.ovh/homestead/shared/env" ) +type FileWriterTo struct { + File fs.File +} + var Files fs.FS func init() { Files = os.DirFS(env.GetEnvFallback("KO_DATA_PATH", "kodata")) } + +func (f FileWriterTo) WriteTo(w io.Writer) (int64, error) { + return io.Copy(w, f.File) +} + +func MakeWriterTo(file fs.File) io.WriterTo { + return &FileWriterTo{file} +}