Compare commits

..

No commits in common. "b76e529ca3ce3005d94244380961e649fb10f682" and "566227773ed5a67ff904df5af45b873014de6f6a" have entirely different histories.

4 changed files with 6 additions and 30 deletions

View File

@ -8,7 +8,7 @@ import (
type Category struct { type Category struct {
*CommonAttributes *CommonAttributes
Content Content `xml:"content"` // undefinedContent in RFC4287 Content Content `xml:"content"` // should this even exist in here?
Term string `xml:"term,attr"` Term string `xml:"term,attr"`
Scheme URI `xml:"scheme,attr,omitempty"` Scheme URI `xml:"scheme,attr,omitempty"`
Label string `xml:"label,attr,omitempty"` Label string `xml:"label,attr,omitempty"`

13
icon.go
View File

@ -1,26 +1,15 @@
package atomfeed package atomfeed
import ( import "errors"
"errors"
"fmt"
)
type Icon struct { type Icon struct {
*CommonAttributes *CommonAttributes
URI URI `xml:"uri"` URI URI `xml:"uri"`
} }
func NewIcon(uri string) *Icon {
return &Icon{URI: URI(uri)}
}
func (i *Icon) Check() error { func (i *Icon) Check() error {
if i.URI == "" { if i.URI == "" {
return errors.New("uri element of icon empty") return errors.New("uri element of icon empty")
} else {
if !isValidURI(i.URI) {
return fmt.Errorf("uri attribute %v of icon not correctly formatted", i.URI)
}
} }
return nil return nil

4
id.go
View File

@ -19,10 +19,6 @@ func NewID() *ID {
func (i *ID) Check() error { func (i *ID) Check() error {
if i.URI == "" { if i.URI == "" {
return errors.New("uri element of id empty") return errors.New("uri element of id empty")
} else {
if !isValidURI(i.URI) {
return fmt.Errorf("uri element %v of id not correctly formatted", i.URI)
}
} }
return nil return nil

17
link.go
View File

@ -7,8 +7,8 @@ import (
type Link struct { type Link struct {
*CommonAttributes *CommonAttributes
Title Text `xml:"title,attr,omitempty"` Title *Text `xml:"title,attr,omitempty"`
Content Content `xml:"content"` // undefinedContent in RFC4287 Content *Content `xml:"content"`
Href URI `xml:"href,attr"` Href URI `xml:"href,attr"`
Rel string `xml:"rel,attr,omitempty"` Rel string `xml:"rel,attr,omitempty"`
Type MediaType `xml:"type,attr,omitempty"` Type MediaType `xml:"type,attr,omitempty"`
@ -16,22 +16,13 @@ type Link struct {
Length uint `xml:"length,attr,omitempty"` Length uint `xml:"length,attr,omitempty"`
} }
func NewLink(href string) (*Link, error) {
content, err := NewContent(InlineText, "", "")
if err != nil {
return nil, fmt.Errorf("error creating content element: %v", err)
}
return &Link{Href: URI(href), Content: content}, nil
}
func (l *Link) Check() error { func (l *Link) Check() error {
if l.Href == "" { if l.Href == "" {
return errors.New("href attribute of link empty") return errors.New("href attribute of link empty")
} }
if l.Title != nil { if l.Title != nil {
if err := l.Title.Check(); err != nil { if err := (*l.Title).Check(); err != nil {
return fmt.Errorf("title attribute of link %v: %v", l.Href, err) return fmt.Errorf("title attribute of link %v: %v", l.Href, err)
} }
} }
@ -39,7 +30,7 @@ func (l *Link) Check() error {
if l.Content == nil { if l.Content == nil {
return fmt.Errorf("no content element of link %v", l.Href) return fmt.Errorf("no content element of link %v", l.Href)
} else { } else {
if err := l.Content.Check(); err != nil { if err := (*l.Content).Check(); err != nil {
return fmt.Errorf("content element of link %v: %v", l.Href, err) return fmt.Errorf("content element of link %v: %v", l.Href, err)
} }
} }