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 {
switch contentType {
case 0:
return newInlineTextContent(mediaType, content.(string))
if stringContent, ok := content.(string); ok {
return newInlineTextContent(mediaType, stringContent)
}
return nil
case 1:
return newInlineXHTMLContent(mediaType, content.(*XHTMLDiv))
if xhtmlDivContent, ok := content.(*XHTMLDiv); ok {
return newInlineXHTMLContent(mediaType, xhtmlDivContent)
}
return nil
case 2:
return newInlineOtherContent(mediaType, content)
case 3:
return newOutOfLineContent(mediaType, content.(string))
if stringContent, ok := content.(string); ok {
return newOutOfLineContent(mediaType, stringContent)
}
return nil
default:
return nil
}

4
go.mod
View File

@@ -1,8 +1,8 @@
module git.streifling.com/jason/atom
go 1.23.2
go 1.24.0
require (
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/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=

View File

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

View File

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