Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit 1adf32a

Browse files
committed
cleanup code
1 parent 5248741 commit 1adf32a

1 file changed

Lines changed: 5 additions & 16 deletions

File tree

cmd/rudi/encoding/decode.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func Decode(input io.Reader, enc types.Encoding) (any, error) {
6363
case types.YamlEncoding:
6464
decoded, err := decodeYaml(input)
6565
if err != nil {
66-
return nil, fmt.Errorf("failed to parse file as JSON5: %w", err)
66+
return nil, err
6767
}
6868

6969
switch len(decoded) {
@@ -76,23 +76,12 @@ func Decode(input io.Reader, enc types.Encoding) (any, error) {
7676
}
7777

7878
case types.YamlDocumentsEncoding:
79-
decoder := yaml.NewDecoder(input)
80-
81-
documents := []any{}
82-
for {
83-
var doc any
84-
if err := decoder.Decode(&doc); err != nil {
85-
if errors.Is(err, io.EOF) {
86-
break
87-
}
88-
89-
return nil, fmt.Errorf("failed to parse file as YAML: %w", err)
90-
}
91-
92-
documents = append(documents, doc)
79+
decoded, err := decodeYaml(input)
80+
if err != nil {
81+
return nil, err
9382
}
9483

95-
data = documents
84+
data = decoded
9685

9786
case types.TomlEncoding:
9887
decoder := toml.NewDecoder(input)

0 commit comments

Comments
 (0)