Commit 44c82dbac6d62ac87b323ca5eef0d7ecfad4db89
1 parent
3ad172fb64
Exists in
master
simplified file reading
Showing
1 changed file
with
3 additions
and
11 deletions
Show diff stats
payload.go
... | ... | @@ -282,6 +282,7 @@ func LoadMetadataFromFile(path string) error { |
282 | 282 | |
283 | 283 | var name string |
284 | 284 | for i, l := range lines { |
285 | + fmt.Println(l) | |
285 | 286 | l = strings.TrimSpace(l) |
286 | 287 | if len(l) == 0 { |
287 | 288 | continue |
... | ... | @@ -327,18 +328,9 @@ func ReadFileLines(path string) ([]string, error) { |
327 | 328 | defer f.Close() |
328 | 329 | |
329 | 330 | var s strings.Builder |
330 | - for { | |
331 | - buf := make([]byte, 1024) | |
332 | - n, err := f.Read(buf) | |
333 | - if err != nil { | |
334 | - if err == io.EOF { | |
335 | - break | |
336 | - } | |
337 | 331 | |
338 | - return nil, err | |
339 | - } | |
340 | - | |
341 | - s.Write(buf[:n]) | |
332 | + if _, err = io.Copy(&s, f); err != nil { | |
333 | + return nil, err | |
342 | 334 | } |
343 | 335 | |
344 | 336 | lines := strings.Split(s.String(), "\n") | ... | ... |