Create method to extend person construct
This commit is contained in:
parent
d2a050bd8f
commit
fe4d539e91
@ -1,6 +1,7 @@
|
|||||||
package atomfeed
|
package atomfeed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/xml"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
@ -17,6 +18,10 @@ func NewPerson(name string) *Person {
|
|||||||
return &Person{Name: name}
|
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 {
|
func (p *Person) Check() error {
|
||||||
if p.Name == "" {
|
if p.Name == "" {
|
||||||
return errors.New("name element of person element empty")
|
return errors.New("name element of person element empty")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user