test marshalling a just-a-string todo returns just-a-string

This commit is contained in:
Bel LaPointe
2021-12-31 16:47:00 -05:00
parent b11d76a8f6
commit 6c83f4197d
2 changed files with 50 additions and 0 deletions

View File

@@ -16,6 +16,14 @@ func (todo Todo) Triggered() bool {
return err == nil && time.Now().After(next)
}
func (todo Todo) MarshalYAML() (interface{}, error) {
if todo == (Todo{Todo: todo.Todo}) {
return todo.Todo, nil
}
type Alt Todo
return (Alt)(todo), nil
}
func (todo *Todo) UnmarshalYAML(unmarshal func(interface{}) error) error {
*todo = Todo{}
if err := unmarshal(&todo.Todo); err == nil {