Create method to extend person construct

This commit is contained in:
Jason Streifling 2024-10-15 16:19:47 +02:00
parent d2a050bd8f
commit fe4d539e91

View File

@ -1,6 +1,7 @@
package atomfeed
import (
"encoding/xml"
"errors"
"fmt"
)
@ -17,6 +18,10 @@ func NewPerson(name string) *Person {
return &Person{Name: name}
}
func (p *Person) AddExtension(name string, value any) {
p.Extensions = append(p.Extensions, &ExtensionElement{XMLName: xml.Name{Local: name}, Value: value})
}
func (p *Person) Check() error {
if p.Name == "" {
return errors.New("name element of person element empty")