Get rid of checks when creating constructs. Check should handle this.
This commit is contained in:
30
person.go
30
person.go
@@ -1,7 +1,6 @@
|
||||
package atom
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/mail"
|
||||
)
|
||||
@@ -14,38 +13,19 @@ type Person struct {
|
||||
Extensions []*ExtensionElement `xml:",any,omitempty"`
|
||||
}
|
||||
|
||||
// NewPerson creates a new Person. It returns a *Person and an error.
|
||||
func NewPerson(name string) (*Person, error) {
|
||||
if name == "" {
|
||||
return nil, errors.New("error creating new person: name string empty")
|
||||
}
|
||||
|
||||
return &Person{Name: name}, nil
|
||||
// NewPerson creates a new Person. It returns a *Person.
|
||||
func NewPerson(name string) *Person {
|
||||
return &Person{Name: name}
|
||||
}
|
||||
|
||||
// SetURI sets the URI element of the Person. It returns an error.
|
||||
func (l *Link) SetURI(uri string) error {
|
||||
if !isValidIRI(uri) {
|
||||
return fmt.Errorf("uri %v not correctly formatted", uri)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddExtension adds the Extension to the Person. It returns an error.
|
||||
func (p *Person) AddExtension(e *ExtensionElement) error {
|
||||
if e == nil {
|
||||
return errors.New("error adding extension element to person: *ExtensionElement is nil")
|
||||
}
|
||||
|
||||
// AddExtension adds the Extension to the Person.
|
||||
func (p *Person) AddExtension(e *ExtensionElement) {
|
||||
if p.Extensions == nil {
|
||||
p.Extensions = make([]*ExtensionElement, 1)
|
||||
p.Extensions[0] = e
|
||||
} else {
|
||||
p.Extensions = append(p.Extensions, e)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check checks the Person for incompatibilities with RFC4287. It returns an
|
||||
|
Reference in New Issue
Block a user