File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 11package metric
22
3+ import (
4+ "errors"
5+ "strings"
6+ )
7+
38// BOOL is an int32 for structure align.
49type BOOL int32
510
@@ -15,6 +20,24 @@ func (b BOOL) String() string {
1520 return "false"
1621}
1722
23+ // MarshalText is used to implement TextMarshaler interface.
24+ func (b BOOL ) MarshalText () ([]byte , error ) {
25+ return []byte (b .String ()), nil
26+ }
27+
28+ // UnmarshalText is used to implement TextUnmarshaler interface.
29+ func (b * BOOL ) UnmarshalText (data []byte ) error {
30+ switch strings .ToLower (string (data )) {
31+ case "true" :
32+ * b = BOOL (1 )
33+ case "false" :
34+ * b = BOOL (0 )
35+ default :
36+ return errors .New ("invalid BOOL value" )
37+ }
38+ return nil
39+ }
40+
1841// Metrics contains status about runtime submodules.
1942type Metrics struct {
2043 Library LTStatus `toml:"library" json:"library"`
You can’t perform that action at this time.
0 commit comments