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
|
package atomfeed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// It is advisable that each atom:entry element contain a non-empty atom:title
|
// 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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Entry) AddExtension(name string, value any) {
|
// AddExtension adds the extension to the entry
|
||||||
e.Extensions = append(e.Extensions, &ExtensionElement{XMLName: xml.Name{Local: name}, Value: value})
|
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 {
|
func (e *Entry) Check() error {
|
||||||
|
11
person.go
11
person.go
@ -1,7 +1,6 @@
|
|||||||
package atomfeed
|
package atomfeed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
@ -19,8 +18,14 @@ func NewPerson(name string) *Person {
|
|||||||
return &Person{Name: name}
|
return &Person{Name: name}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Person) AddExtension(name string, value any) {
|
// AddExtension adds the extension to the person
|
||||||
p.Extensions = append(p.Extensions, &ExtensionElement{XMLName: xml.Name{Local: name}, Value: value})
|
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 {
|
func (p *Person) Check() error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user