diff --git a/category.go b/category.go index fb0006a..28358c3 100644 --- a/category.go +++ b/category.go @@ -15,7 +15,10 @@ type Category struct { // NewCategory creates a new Category. It returns a *Category. func NewCategory(term string) *Category { - return &Category{Term: term} + return &Category{ + CommonAttributes: newCommonAttributes(), + Term: term, + } } // SetLabel sets the Label attribute of the Category. diff --git a/commonAttributes.go b/commonAttributes.go index 613983a..477ede5 100644 --- a/commonAttributes.go +++ b/commonAttributes.go @@ -13,7 +13,7 @@ type CommonAttributes struct { // NewCommonAttributes creates a new set of CommonAttributes. It returns a // *CommonAttributes. -func NewCommonAttributes() *CommonAttributes { +func newCommonAttributes() *CommonAttributes { return new(CommonAttributes) } diff --git a/date.go b/date.go index a587be8..809ad0b 100644 --- a/date.go +++ b/date.go @@ -18,7 +18,10 @@ func DateTime(t time.Time) string { // NewDate creates a new Date. It returns a *Date. func NewDate(t time.Time) *Date { - return &Date{DateTime: DateTime(t)} + return &Date{ + CommonAttributes: newCommonAttributes(), + DateTime: DateTime(t), + } } // Check checks the Date for incompatibilities with RFC4287. It returns an diff --git a/entry.go b/entry.go index db7b4a4..802be20 100644 --- a/entry.go +++ b/entry.go @@ -59,9 +59,10 @@ func (e *Entry) checkAuthors(authorInFeed bool) error { // NewEntry creates a new Entry. It returns a *Entry. func NewEntry(title string) *Entry { return &Entry{ - ID: NewID(NewURN()), - Title: NewText("text", title), - Updated: NewDate(time.Now()), + CommonAttributes: newCommonAttributes(), + ID: NewID(NewURN()), + Title: NewText("text", title), + Updated: NewDate(time.Now()), } } diff --git a/feed.go b/feed.go index 7b66005..22d72fb 100644 --- a/feed.go +++ b/feed.go @@ -28,9 +28,10 @@ type Feed struct { // NewFeed creates a new Feed. It returns a *Feed. func NewFeed(title string) *Feed { return &Feed{ - ID: NewID(NewURN()), - Title: NewText("text", title), - Updated: NewDate(time.Now()), + CommonAttributes: newCommonAttributes(), + ID: NewID(NewURN()), + Title: NewText("text", title), + Updated: NewDate(time.Now()), } } diff --git a/generator.go b/generator.go index f6030c9..ed859b8 100644 --- a/generator.go +++ b/generator.go @@ -16,7 +16,10 @@ type Generator struct { // NewGenerator creates a new Generator. It returns a *Generator. func NewGenerator(text string) *Generator { - return &Generator{Text: html.UnescapeString(text)} + return &Generator{ + CommonAttributes: newCommonAttributes(), + Text: html.UnescapeString(text), + } } // Check checks the Generator for incompatibilities with RFC4287. It returns an diff --git a/icon.go b/icon.go index 7bd8148..c33cb33 100644 --- a/icon.go +++ b/icon.go @@ -14,7 +14,10 @@ type Icon struct { // NewIcon creates a new Icon. It returns a *Icon. func NewIcon(uri string) *Icon { - return &Icon{URI: uri} + return &Icon{ + CommonAttributes: newCommonAttributes(), + URI: uri, + } } // Check checks the Icon for incompatibilities with RFC4287. It returns an diff --git a/id.go b/id.go index 15f8f9d..71d6561 100644 --- a/id.go +++ b/id.go @@ -14,7 +14,10 @@ type ID struct { // NewID creates a new ID. It returns a *ID. func NewID(uri string) *ID { - return &ID{URI: uri} + return &ID{ + CommonAttributes: newCommonAttributes(), + URI: uri, + } } // Check checks the ID for incompatibilities with RFC4287. It returns an error. diff --git a/inlineOtherContent.go b/inlineOtherContent.go index 1922122..112d2fb 100644 --- a/inlineOtherContent.go +++ b/inlineOtherContent.go @@ -17,7 +17,12 @@ type InlineOtherContent struct { // *InlineOtherContent and an error. func newInlineOtherContent(mediaType string, content any) *InlineOtherContent { mediaType, _, _ = mime.ParseMediaType(mediaType) - return &InlineOtherContent{Type: mediaType, AnyElement: content} + + return &InlineOtherContent{ + CommonAttributes: newCommonAttributes(), + Type: mediaType, + AnyElement: content, + } } // isContent checks whether the InlineOtherContent is a Content. It returns a diff --git a/inlineTextContent.go b/inlineTextContent.go index 7dc76b4..0c256f3 100644 --- a/inlineTextContent.go +++ b/inlineTextContent.go @@ -15,7 +15,11 @@ type InlineTextContent struct { // newInlineTextContent creates a new InlineTextContent. It returns a // *InlineTextContent. func newInlineTextContent(mediaType, text string) *InlineTextContent { - return &InlineTextContent{Type: mediaType, Text: text} + return &InlineTextContent{ + CommonAttributes: newCommonAttributes(), + Type: mediaType, + Text: text, + } } // isContent checks whether the InlineTextContent is a Content. It returns a diff --git a/inlineXHTMLContent.go b/inlineXHTMLContent.go index 755d871..872bed8 100644 --- a/inlineXHTMLContent.go +++ b/inlineXHTMLContent.go @@ -15,7 +15,11 @@ type InlineXHTMLContent struct { // newInlineXHTMLContent creates a new InlineXHTMLContent. It returns a // *InlineXHTMLContent. func newInlineXHTMLContent(mediaType string, div *XHTMLDiv) *InlineXHTMLContent { - return &InlineXHTMLContent{Type: mediaType, XHTMLDiv: div} + return &InlineXHTMLContent{ + CommonAttributes: newCommonAttributes(), + Type: mediaType, + XHTMLDiv: div, + } } // isContent checks whether the InlineXHTMLContent is a Content. It returns a diff --git a/link.go b/link.go index 18b57c6..0deb005 100644 --- a/link.go +++ b/link.go @@ -19,7 +19,10 @@ type Link struct { // NewLink creates a new Link. It returns a *Link. func NewLink(href string) *Link { - return &Link{Href: href} + return &Link{ + CommonAttributes: newCommonAttributes(), + Href: href, + } } // Check checks the Link for incompatibilities with RFC4287. It returns an diff --git a/logo.go b/logo.go index 802994e..a35843f 100644 --- a/logo.go +++ b/logo.go @@ -13,7 +13,10 @@ type Logo struct { // NewLogo creates a new Logo. It returns a *Logo. func NewLogo(uri string) *Logo { - return &Logo{URI: uri} + return &Logo{ + CommonAttributes: newCommonAttributes(), + URI: uri, + } } // Check checks the Logo for incompatibilities with RFC4287. It returns an diff --git a/outOfLineContent.go b/outOfLineContent.go index a6f60a6..47ea848 100644 --- a/outOfLineContent.go +++ b/outOfLineContent.go @@ -17,7 +17,12 @@ type OutOfLineContent struct { // *OutOfLineContent. func newOutOfLineContent(mediaType, src string) *OutOfLineContent { mediaType, _, _ = mime.ParseMediaType(mediaType) - return &OutOfLineContent{Type: mediaType, SRC: src} + + return &OutOfLineContent{ + CommonAttributes: newCommonAttributes(), + Type: mediaType, + SRC: src, + } } // isContent checks whether the OutOfLineContent is a Content. It returns a diff --git a/person.go b/person.go index ef77cfd..133e30b 100644 --- a/person.go +++ b/person.go @@ -15,7 +15,10 @@ type Person struct { // NewPerson creates a new Person. It returns a *Person. func NewPerson(name string) *Person { - return &Person{Name: name} + return &Person{ + CommonAttributes: newCommonAttributes(), + Name: name, + } } // AddExtension adds the Extension to the Person. diff --git a/plainText.go b/plainText.go index 7403391..651f22a 100644 --- a/plainText.go +++ b/plainText.go @@ -15,7 +15,11 @@ func (p *PlainText) isText() bool { return true } // newPlainText creates a new PlainText. It returns a *PlainText. func newPlainText(textType, content string) *PlainText { - return &PlainText{Type: textType, Text: content} + return &PlainText{ + CommonAttributes: newCommonAttributes(), + Type: textType, + Text: content, + } } // Check checks the PlainText for incompatibilities with RFC4287. It returns an diff --git a/source.go b/source.go index f30981c..91ba816 100644 --- a/source.go +++ b/source.go @@ -25,7 +25,7 @@ type Source struct { // NewSource creates a new Source. It returns a *Source. func NewSource() *Source { - return new(Source) + return &Source{CommonAttributes: newCommonAttributes()} } // Check checks the Source for incompatibilities with RFC4287. It returns an diff --git a/xhtmlText.go b/xhtmlText.go index ea57804..26ffac8 100644 --- a/xhtmlText.go +++ b/xhtmlText.go @@ -16,8 +16,9 @@ func (x *XHTMLText) isText() bool { return true } // newPlainText creates a new PlainText. It returns a *PlainText. func newXHTMLText(textType, content string) *XHTMLText { return &XHTMLText{ - Type: textType, - XHTMLDiv: NewXHTMLDiv(content), + CommonAttributes: newCommonAttributes(), + Type: textType, + XHTMLDiv: NewXHTMLDiv(content), } }