Correct AddExtension for entry and person
This commit is contained in:
parent
082e71a698
commit
39bd0776c5
14
entry.go
14
entry.go
@ -1,10 +1,10 @@
|
||||
package atomfeed
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// It is advisable that each atom:entry element contain a non-empty atom:title
|
||||
@ -58,8 +58,16 @@ func alternateRelExists(l []*Link) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (e *Entry) AddExtension(name string, value any) {
|
||||
e.Extensions = append(e.Extensions, &ExtensionElement{XMLName: xml.Name{Local: name}, Value: value})
|
||||
// AddExtension adds the extension to the entry
|
||||
func (e *Entry) AddExtension(x *ExtensionElement) {
|
||||
if e.Extensions == nil {
|
||||
e.Extensions = make([]*ExtensionElement, 1)
|
||||
e.Extensions[0] = x
|
||||
} else {
|
||||
e.Extensions = append(e.Extensions, x)
|
||||
}
|
||||
|
||||
e.Updated.DateTime = DateTime(time.Now())
|
||||
}
|
||||
|
||||
func (e *Entry) Check() error {
|
||||
|
11
person.go
11
person.go
@ -1,7 +1,6 @@
|
||||
package atomfeed
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/mail"
|
||||
@ -19,8 +18,14 @@ 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})
|
||||
// AddExtension adds the extension to the person
|
||||
func (p *Person) AddExtension(e *ExtensionElement) {
|
||||
if p.Extensions == nil {
|
||||
p.Extensions = make([]*ExtensionElement, 1)
|
||||
p.Extensions[0] = e
|
||||
} else {
|
||||
p.Extensions = append(p.Extensions, e)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Person) Check() error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user