3 Commits

Author SHA1 Message Date
f3019ff7e8 Update dependencies 2025-10-07 19:27:21 +02:00
d6310ee8ee Beauty fixes 2025-10-07 19:21:53 +02:00
a65920aa70 Check type assertions for content types 2025-10-07 19:07:33 +02:00
5 changed files with 18 additions and 13 deletions

View File

@@ -21,13 +21,22 @@ type Content interface {
func NewContent(contentType int, mediaType string, content any) Content { func NewContent(contentType int, mediaType string, content any) Content {
switch contentType { switch contentType {
case 0: case 0:
return newInlineTextContent(mediaType, content.(string)) if stringContent, ok := content.(string); ok {
return newInlineTextContent(mediaType, stringContent)
}
return nil
case 1: case 1:
return newInlineXHTMLContent(mediaType, content.(*XHTMLDiv)) if xhtmlDivContent, ok := content.(*XHTMLDiv); ok {
return newInlineXHTMLContent(mediaType, xhtmlDivContent)
}
return nil
case 2: case 2:
return newInlineOtherContent(mediaType, content) return newInlineOtherContent(mediaType, content)
case 3: case 3:
return newOutOfLineContent(mediaType, content.(string)) if stringContent, ok := content.(string); ok {
return newOutOfLineContent(mediaType, stringContent)
}
return nil
default: default:
return nil return nil
} }

4
go.mod
View File

@@ -1,8 +1,8 @@
module git.streifling.com/jason/atom module git.streifling.com/jason/atom
go 1.23.2 go 1.24.0
require ( require (
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
golang.org/x/text v0.19.0 golang.org/x/text v0.29.0
) )

4
go.sum
View File

@@ -1,4 +1,4 @@
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=

View File

@@ -1,8 +1,6 @@
package atom package atom
import ( import "fmt"
"fmt"
)
type PlainText struct { type PlainText struct {
*CommonAttributes *CommonAttributes

View File

@@ -1,8 +1,6 @@
package atom package atom
import ( import "fmt"
"fmt"
)
type XHTMLText struct { type XHTMLText struct {
*CommonAttributes *CommonAttributes