Skip to content

Commit c5a6726

Browse files
authored
Capture io.EOF error (#4)
1 parent 77bec26 commit c5a6726

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

root.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package seer
22

33
import (
4+
"errors"
45
"fmt"
6+
"io"
57
"os"
68
"strings"
79

@@ -76,11 +78,12 @@ func (s *Seer) loadYamlDocument(path string) (*yaml.Node, error) {
7678
if err != nil {
7779
return nil, fmt.Errorf("Opening yaml file %s failed with %s", path, err.Error())
7880
}
81+
defer f.Close()
7982

8083
root_node := &yaml.Node{}
8184
yaml_decoder := yaml.NewDecoder(f)
8285
err = yaml_decoder.Decode(root_node)
83-
if err != nil {
86+
if err != nil && !errors.Is(err, io.EOF) {
8487
return nil, fmt.Errorf("Processing yaml file %s failed with %s", path, err.Error())
8588
}
8689

0 commit comments

Comments
 (0)