Implement lifecycle
This commit is contained in:
1 parent
8a2a65d8ed
commit
c4abdaa54b
21 files changed
+582
-173
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package xtypes
|
||||
|
||||
type Bool struct {
|
||||
Value bool
|
||||
}
|
||||
|
||||
func (l Bool) MarshalJSON() ([]byte, error) {
|
||||
return l.MarshalText()
|
||||
}
|
||||
|
||||
func (l *Bool) UnmarshalJSON(data []byte) error {
|
||||
return l.UnmarshalText(data)
|
||||
}
|
||||
|
||||
func (l Bool) MarshalText() ([]byte, error) {
|
||||
if l.Value {
|
||||
return []byte("1"), nil
|
||||
}
|
||||
return []byte("0"), nil
|
||||
}
|
||||
|
||||
func (l *Bool) UnmarshalText(data []byte) error {
|
||||
l.Value = string(data) == "1"
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user