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

enetx / g / 21289755465

23 Jan 2026 02:33PM UTC coverage: 90.02% (+0.02%) from 89.997%
21289755465

push

github

enetx
feat(option): add JSON marshal/unmarshal support; fix PathSeparator typo

14 of 16 new or added lines in 1 file covered. (87.5%)

6 existing lines in 2 files now uncovered.

6431 of 7144 relevant lines covered (90.02%)

313.03 hits per line

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

87.5
/option_json.go
1
package g
2

3
import "encoding/json"
4

5
// MarshalJSON implements the json.Marshaler interface for Option[T].
6
// Some(value) is marshaled as the JSON representation of value.
7
// None is marshaled as null.
8
func (o Option[T]) MarshalJSON() ([]byte, error) {
27✔
9
        if o.IsNone() {
35✔
10
                return []byte("null"), nil
8✔
11
        }
8✔
12

13
        return json.Marshal(o.v)
19✔
14
}
15

16
// UnmarshalJSON implements the json.Unmarshaler interface for Option[T].
17
// JSON null is unmarshaled as None.
18
// Any other valid JSON value is unmarshaled as Some(value).
19
func (o *Option[T]) UnmarshalJSON(data []byte) error {
16✔
20
        if string(data) == "null" {
22✔
21
                *o = None[T]()
6✔
22
                return nil
6✔
23
        }
6✔
24

25
        var v T
10✔
26
        if err := json.Unmarshal(data, &v); err != nil {
10✔
NEW
27
                return err
×
NEW
28
        }
×
29

30
        *o = Some(v)
10✔
31
        return nil
10✔
32
}
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