From 44c82dbac6d62ac87b323ca5eef0d7ecfad4db89 Mon Sep 17 00:00:00 2001 From: "marko.tikvic" Date: Tue, 5 Feb 2019 10:08:23 +0100 Subject: [PATCH] simplified file reading --- payload.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/payload.go b/payload.go index b233e4f..69af8dc 100644 --- a/payload.go +++ b/payload.go @@ -282,6 +282,7 @@ func LoadMetadataFromFile(path string) error { var name string for i, l := range lines { + fmt.Println(l) l = strings.TrimSpace(l) if len(l) == 0 { continue @@ -327,18 +328,9 @@ func ReadFileLines(path string) ([]string, error) { defer f.Close() var s strings.Builder - for { - buf := make([]byte, 1024) - n, err := f.Read(buf) - if err != nil { - if err == io.EOF { - break - } - return nil, err - } - - s.Write(buf[:n]) + if _, err = io.Copy(&s, f); err != nil { + return nil, err } lines := strings.Split(s.String(), "\n") -- 1.8.1.2