33 lines
589 B
Go
33 lines
589 B
Go
package atom
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Logo struct {
|
|
*CommonAttributes
|
|
URI IRI `xml:"uri"`
|
|
}
|
|
|
|
// NewLogo creates a new Logo. It returns a *Logo.
|
|
func NewLogo() *Logo {
|
|
return &Logo{URI: IRI(fmt.Sprint("urn:uuid:", uuid.New()))}
|
|
}
|
|
|
|
// Check checks the Logo for incompatibilities with RFC4287. It returns an
|
|
// error.
|
|
func (l *Logo) Check() error {
|
|
if l.URI == "" {
|
|
return errors.New("uri element of logo empty")
|
|
} else {
|
|
if !isValidIRI(l.URI) {
|
|
return fmt.Errorf("uri element %v of logo not correctly formatted", l.URI)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|