Get rid of checks when creating constructs. Check should handle this.
This commit is contained in:
43
category.go
43
category.go
@@ -2,9 +2,7 @@ package atom
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html"
|
||||
)
|
||||
|
||||
type Category struct {
|
||||
@@ -15,43 +13,14 @@ type Category struct {
|
||||
Label string `xml:"label,attr,omitempty"`
|
||||
}
|
||||
|
||||
// NewCategory creates a new Category. It returns a *Category and an error.
|
||||
func NewCategory(term string) (*Category, error) {
|
||||
if term == "" {
|
||||
return nil, errors.New("error creating new category: term string empty")
|
||||
}
|
||||
|
||||
return &Category{Term: term}, nil
|
||||
// NewCategory creates a new Category. It returns a *Category.
|
||||
func NewCategory(term string) *Category {
|
||||
return &Category{Term: term}
|
||||
}
|
||||
|
||||
// SetTerm sets the Term attribute of the Category. It returns an error.
|
||||
func (c *Category) SetTerm(t string) error {
|
||||
if t == "" {
|
||||
return errors.New("error setting term of category: t string empty")
|
||||
}
|
||||
|
||||
c.Term = t
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetScheme sets the Scheme attribute of the Category. It returns an error.
|
||||
func (c *Category) SetScheme(s string) error {
|
||||
if !isValidIRI(s) {
|
||||
return fmt.Errorf("scheme %v not correctly formatted", s)
|
||||
}
|
||||
|
||||
c.Scheme = s
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetLabel sets the Label attribute of the Category. It returns an error.
|
||||
func (c *Category) SetLabel(label string) error {
|
||||
if label == "" {
|
||||
return errors.New("error setting label of category: label string empty")
|
||||
}
|
||||
|
||||
c.Label = html.UnescapeString(label)
|
||||
return nil
|
||||
// SetLabel sets the Label attribute of the Category.
|
||||
func (c *Category) SetLabel(label string) {
|
||||
c.Label = Unescape(label)
|
||||
}
|
||||
|
||||
// Check checks the Category for incompatibilities with RFC4287. It returns an
|
||||
|
Reference in New Issue
Block a user