2024-10-16 21:28:04 +02:00
|
|
|
package atom
|
2024-10-13 17:19:40 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2024-10-17 20:48:32 +02:00
|
|
|
"fmt"
|
2024-10-13 17:19:40 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type ExtensionAttribute struct {
|
2024-10-17 20:48:32 +02:00
|
|
|
Attr string `xml:",attr"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewExtensionAttribute creates a new ExtensionAttribute. It returns a
|
|
|
|
// *ExtensionAttribute.
|
|
|
|
func NewExtensionAttribute(name, value string) *ExtensionAttribute {
|
|
|
|
return &ExtensionAttribute{Attr: fmt.Sprint(name, `="`, value, `"`)}
|
2024-10-13 17:19:40 +02:00
|
|
|
}
|
|
|
|
|
2024-10-16 19:59:28 +02:00
|
|
|
// Check checks the ExtensionAttribute for incompatibilities with RFC4287. It
|
|
|
|
// returns an error.
|
2024-10-13 17:19:40 +02:00
|
|
|
func (e *ExtensionAttribute) Check() error {
|
2024-10-17 20:48:32 +02:00
|
|
|
if e.Attr == "" {
|
2024-10-13 17:19:40 +02:00
|
|
|
return errors.New("value element of extension attribute empty")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|