atom/extensionAttribute.go

28 lines
604 B
Go
Raw Normal View History

2024-10-17 21:27:54 +02:00
package atom
import (
"encoding/xml"
"errors"
)
type ExtensionAttribute struct {
XMLName xml.Name
Value string
}
// NewExtensionAttribute creates a new ExtensionAttribute. It returns a
// *ExtensionAttribute.
func NewExtensionAttribute(name, value string) *ExtensionAttribute {
return &ExtensionAttribute{XMLName: xml.Name{Local: name}, Value: value}
}
// Check checks the ExtensionAttribute for incompatibilities with RFC4287. It
// returns an error.
func (e *ExtensionAttribute) Check() error {
if e.Value == "" {
return errors.New("value of extension attribute empty")
}
return nil
}