• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MordaTeam / go-config / 21989086970

13 Feb 2026 01:45PM UTC coverage: 80.791% (-0.08%) from 80.87%
21989086970

push

github

horockey
hotfix: func signature

12 of 14 new or added lines in 1 file covered. (85.71%)

286 of 354 relevant lines covered (80.79%)

0.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/fallback_decoder.go
1
package config
2

3
import (
4
        "bytes"
5
        "errors"
6
        "fmt"
7
        "io"
8
)
9

10
var _ Decoder = &fallbackDecoder{}
11

12
type fallbackDecoder struct {
13
        decCtrs []func(io.Reader) Decoder
14
        reader  io.Reader
15
}
16

17
// Creates new fallback line of decoders.
18
// Call for Decode() returns first successfull result of Decode() call of internal decoder.
19
// If all internal decoders fail, return resulting error.
20
func FallbackDecoder(decCtrs ...func(io.Reader) Decoder) func(r io.Reader) *fallbackDecoder {
1✔
21
        return func(r io.Reader) *fallbackDecoder {
2✔
22
                return &fallbackDecoder{
1✔
23
                        decCtrs: decCtrs,
1✔
24
                        reader:  r,
1✔
25
                }
1✔
26
        }
1✔
27
}
28

29
func (dec *fallbackDecoder) Decode(v any) error {
1✔
30
        data, err := io.ReadAll(dec.reader)
1✔
31
        if err != nil {
1✔
NEW
32
                return fmt.Errorf("reading data from reader: %w", err)
×
NEW
33
        }
×
34

35
        var resErr error
1✔
36
        for idx, dCtr := range dec.decCtrs {
2✔
37
                if dCtr == nil {
2✔
38
                        resErr = errors.Join(resErr, fmt.Errorf("nil decoder constructor on pos %d", idx))
1✔
39
                        continue
1✔
40
                }
41

42
                d := dCtr(bytes.NewReader(data))
1✔
43

1✔
44
                if err := d.Decode(v); err != nil {
2✔
45
                        resErr = errors.Join(resErr, fmt.Errorf("decoding on pos %d: %w", idx, err))
1✔
46
                        continue
1✔
47
                }
48

49
                return nil
1✔
50
        }
51

52
        return resErr
1✔
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc