From fe4d539e91b087801f01a24bf2aed79de66e6d88 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Tue, 15 Oct 2024 16:19:47 +0200 Subject: [PATCH] Create method to extend person construct --- person.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/person.go b/person.go index 431a4c7..99d9dd3 100644 --- a/person.go +++ b/person.go @@ -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")