Added Delete methods for slice elements to common attributes, entry, feed, person and source
This commit is contained in:
@@ -17,7 +17,7 @@ func newCommonAttributes() *CommonAttributes {
|
||||
return new(CommonAttributes)
|
||||
}
|
||||
|
||||
// AddAttribute adds the Attribute to the CommonAttributes.
|
||||
// AddAttribute adds the attribute to the CommonAttributes.
|
||||
func (c *CommonAttributes) AddAttribute(name, value string) {
|
||||
if c.UndefinedAttributes == nil {
|
||||
c.UndefinedAttributes = make([]*xml.Attr, 1)
|
||||
@@ -27,6 +27,18 @@ func (c *CommonAttributes) AddAttribute(name, value string) {
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteAttribute deletes the attribute from the CommonAttributes. It return an
|
||||
// error.
|
||||
func (c *CommonAttributes) DeleteAttribute(id int) error {
|
||||
length := len(c.UndefinedAttributes)
|
||||
if id > length {
|
||||
return fmt.Errorf("error deleting undefined attribute from common attributes %v: id %v out of range %v", c, id, length)
|
||||
}
|
||||
|
||||
c.UndefinedAttributes = append(c.UndefinedAttributes[:id], c.UndefinedAttributes[id+1:]...)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check checks the CommonAttributes for incompatibilities with RFC4287. It
|
||||
// returns an error.
|
||||
func (c *CommonAttributes) Check() error {
|
||||
|
Reference in New Issue
Block a user