atom/logo.go

35 lines
652 B
Go

package atom
import (
"encoding/xml"
"fmt"
)
type Logo struct {
XMLName xml.Name `xml:"logo"`
*CommonAttributes
URI string `xml:",chardata"` // IRI
}
// NewLogo creates a new Logo. It returns a *Logo.
func NewLogo(uri string) *Logo {
return &Logo{
CommonAttributes: newCommonAttributes(),
URI: uri,
}
}
// Check checks the Logo for incompatibilities with RFC4287. It returns an
// error.
func (l *Logo) Check() error {
if l.URI == "" {
return fmt.Errorf("uri element of logo %v empty", l)
} else {
if !isValidIRI(l.URI) {
return fmt.Errorf("uri element of logo %v not correctly formatted", l)
}
}
return nil
}