From c7c0936a4862f76772abcf15f313c443af18da16 Mon Sep 17 00:00:00 2001 From: "kim (grufwub)" Date: Tue, 6 Oct 2020 22:36:36 +0100 Subject: [PATCH] fix gophermap file sections to be gophermap formatted Signed-off-by: kim (grufwub) --- gopher/gophermap.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gopher/gophermap.go b/gopher/gophermap.go index d9bb6d1..5b9b5a2 100644 --- a/gopher/gophermap.go +++ b/gopher/gophermap.go @@ -189,8 +189,17 @@ func (s *FileSection) RenderAndWrite(client *core.Client) core.Error { return err } - // Read the file contents into memory - b, err := core.FileSystem.ReadFile(fd) + // Byte slice to contain gophermap contents + b := make([]byte, 0) + + // Scan the file contents, format for gophermap, append to byte slice + err = core.FileSystem.ScanFile( + fd, + func(line string) bool { + b = append(b, buildInfoLine(line)...) + return true + }, + ) if err != nil { return err }