Get rid of checks when creating constructs. Check should handle this.
This commit is contained in:
12
content.go
12
content.go
@@ -1,7 +1,5 @@
|
||||
package atom
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
InlineText = iota
|
||||
InlineXHTML
|
||||
@@ -17,17 +15,17 @@ type Content interface {
|
||||
}
|
||||
|
||||
// NewContent creates a new Content. It returns a Content and an error.
|
||||
func NewContent(contentType int, mediaType string, content any) (Content, error) {
|
||||
func NewContent(contentType int, mediaType string, content any) Content {
|
||||
switch contentType {
|
||||
case 0:
|
||||
return newInlineTextContent(mediaType, content)
|
||||
return newInlineTextContent(mediaType, content.(string))
|
||||
case 1:
|
||||
return newInlineXHTMLContent(mediaType, content)
|
||||
return newInlineXHTMLContent(mediaType, content.(*XHTMLDiv))
|
||||
case 2:
|
||||
return newInlineOtherContent(mediaType, content)
|
||||
case 3:
|
||||
return newOutOfLineContent(mediaType, content)
|
||||
return newOutOfLineContent(mediaType, content.(string))
|
||||
default:
|
||||
return nil, fmt.Errorf("error creating new content: %v is not a valid text type", contentType)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user