Compare commits
No commits in common. "764b143ff80387668b822f2ecfb4130401625cf2" and "b6b8970810917aec02df16a5dc6f60275a1cc7bd" have entirely different histories.
764b143ff8
...
b6b8970810
8
atom.go
8
atom.go
@ -26,13 +26,13 @@ func addToSlice[C Countable](slice *[]C, countable C) {
|
||||
|
||||
// deleteFromSlice deletes the Countable with the index from the *[]Countable.
|
||||
// It return an error.
|
||||
func deleteFromSlice[C Countable](slice *[]C, index int) error {
|
||||
func deleteFromSlice[C Countable](slice *[]C, id int) error {
|
||||
length := len(*slice)
|
||||
if index > length {
|
||||
return fmt.Errorf("id %v out of range %v", index, length)
|
||||
if id > length {
|
||||
return fmt.Errorf("id %v out of range %v", id, length)
|
||||
}
|
||||
|
||||
*slice = append((*slice)[:index], (*slice)[index+1:]...)
|
||||
*slice = append((*slice)[:id], (*slice)[id+1:]...)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,11 @@ func (c *CommonAttributes) AddAttribute(name, value string) {
|
||||
addToSlice(&c.UndefinedAttributes, &xml.Attr{Name: xml.Name{Local: name}, Value: value})
|
||||
}
|
||||
|
||||
// DeleteAttribute deletes the attribute at index from the CommonAttributes. It
|
||||
// return an error.
|
||||
func (c *CommonAttributes) DeleteAttribute(index int) error {
|
||||
if err := deleteFromSlice(&c.UndefinedAttributes, index); err != nil {
|
||||
return fmt.Errorf("error deleting undefined attribute %v from common attributes %v: %v", index, c, err)
|
||||
// DeleteAttribute deletes the attribute from the CommonAttributes. It return an
|
||||
// error.
|
||||
func (c *CommonAttributes) DeleteAttribute(id int) error {
|
||||
if err := deleteFromSlice(&c.UndefinedAttributes, id); err != nil {
|
||||
return fmt.Errorf("error deleting undefined attribute %v from common attributes %v: %v", id, c, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
43
entry.go
43
entry.go
@ -72,10 +72,10 @@ func (e *Entry) AddAuthor(p *Person) {
|
||||
e.Updated = NewDate(time.Now())
|
||||
}
|
||||
|
||||
// DeleteAuthor deletes the Person at index from the Entry. It return an error.
|
||||
func (e *Entry) DeleteAuthor(index int) error {
|
||||
if err := deleteFromSlice(&e.Authors, index); err != nil {
|
||||
return fmt.Errorf("error deleting author %v from entry %v: %v", index, e.ID.URI, err)
|
||||
// DeleteAuthor deletes the Person from the Entry. It return an error.
|
||||
func (e *Entry) DeleteAuthor(id int) error {
|
||||
if err := deleteFromSlice(&e.Authors, id); err != nil {
|
||||
return fmt.Errorf("error deleting author %v from entry %v: %v", id, e.ID.URI, err)
|
||||
}
|
||||
|
||||
e.Updated = NewDate(time.Now())
|
||||
@ -88,11 +88,10 @@ func (e *Entry) AddCategory(c *Category) {
|
||||
e.Updated = NewDate(time.Now())
|
||||
}
|
||||
|
||||
// DeleteCategory deletes the Category at index from the Entry. It return an
|
||||
// error.
|
||||
func (e *Entry) DeleteCategory(index int) error {
|
||||
if err := deleteFromSlice(&e.Categories, index); err != nil {
|
||||
return fmt.Errorf("error deleting category %v from entry %v: %v", index, e.ID.URI, err)
|
||||
// DeleteCategory deletes the Category from the Entry. It return an error.
|
||||
func (e *Entry) DeleteCategory(id int) error {
|
||||
if err := deleteFromSlice(&e.Categories, id); err != nil {
|
||||
return fmt.Errorf("error deleting category %v from entry %v: %v", id, e.ID.URI, err)
|
||||
}
|
||||
|
||||
e.Updated = NewDate(time.Now())
|
||||
@ -105,11 +104,10 @@ func (e *Entry) AddContributor(c *Person) {
|
||||
e.Updated = NewDate(time.Now())
|
||||
}
|
||||
|
||||
// DeleteContributor deletes the Person at index from the Entry. It return an
|
||||
// error.
|
||||
func (e *Entry) DeleteContributor(index int) error {
|
||||
if err := deleteFromSlice(&e.Contributors, index); err != nil {
|
||||
return fmt.Errorf("error deleting contributor %v from entry %v: %v", index, e.ID.URI, err)
|
||||
// DeleteContributor deletes the Person from the Entry. It return an error.
|
||||
func (e *Entry) DeleteContributor(id int) error {
|
||||
if err := deleteFromSlice(&e.Contributors, id); err != nil {
|
||||
return fmt.Errorf("error deleting contributor %v from entry %v: %v", id, e.ID.URI, err)
|
||||
}
|
||||
|
||||
e.Updated = NewDate(time.Now())
|
||||
@ -122,10 +120,10 @@ func (e *Entry) AddLink(l *Link) {
|
||||
e.Updated = NewDate(time.Now())
|
||||
}
|
||||
|
||||
// DeleteLink deletes the Link at index from the Entry. It return an error.
|
||||
func (e *Entry) DeleteLink(index int) error {
|
||||
if err := deleteFromSlice(&e.Links, index); err != nil {
|
||||
return fmt.Errorf("error deleting link %v from entry %v: %v", index, e.ID.URI, err)
|
||||
// DeleteLink deletes the Link from the Entry. It return an error.
|
||||
func (e *Entry) DeleteLink(id int) error {
|
||||
if err := deleteFromSlice(&e.Links, id); err != nil {
|
||||
return fmt.Errorf("error deleting link %v from entry %v: %v", id, e.ID.URI, err)
|
||||
}
|
||||
|
||||
e.Updated = NewDate(time.Now())
|
||||
@ -138,11 +136,10 @@ func (e *Entry) AddExtension(x *ExtensionElement) {
|
||||
e.Updated = NewDate(time.Now())
|
||||
}
|
||||
|
||||
// DeleteExtension deletes the Extension at index from the Entry. It return an
|
||||
// error.
|
||||
func (e *Entry) DeleteExtension(index int) error {
|
||||
if err := deleteFromSlice(&e.Extensions, index); err != nil {
|
||||
return fmt.Errorf("error deleting extension %v from entry %v: %v", index, e.ID.URI, err)
|
||||
// DeleteExtension deletes the Extension from the Entry. It return an error.
|
||||
func (e *Entry) DeleteExtension(id int) error {
|
||||
if err := deleteFromSlice(&e.Extensions, id); err != nil {
|
||||
return fmt.Errorf("error deleting extension %v from entry %v: %v", id, e.ID.URI, err)
|
||||
}
|
||||
|
||||
e.Updated = NewDate(time.Now())
|
||||
|
51
feed.go
51
feed.go
@ -41,10 +41,10 @@ func (f *Feed) AddAuthor(p *Person) {
|
||||
f.Updated = NewDate(time.Now())
|
||||
}
|
||||
|
||||
// DeleteAuthor deletes the Person at index from the Feed. It return an error.
|
||||
func (f *Feed) DeleteAuthor(index int) error {
|
||||
if err := deleteFromSlice(&f.Authors, index); err != nil {
|
||||
return fmt.Errorf("error deleting author %v from entry %v: %v", index, f.ID.URI, err)
|
||||
// DeleteAuthor deletes the Person from the Feed. It return an error.
|
||||
func (f *Feed) DeleteAuthor(id int) error {
|
||||
if err := deleteFromSlice(&f.Authors, id); err != nil {
|
||||
return fmt.Errorf("error deleting author %v from entry %v: %v", id, f.ID.URI, err)
|
||||
}
|
||||
|
||||
f.Updated = NewDate(time.Now())
|
||||
@ -57,11 +57,10 @@ func (f *Feed) AddCategory(c *Category) {
|
||||
f.Updated = NewDate(time.Now())
|
||||
}
|
||||
|
||||
// DeleteCategory deletes the Category at index from the Feed. It return an
|
||||
// error.
|
||||
func (f *Feed) DeleteCategory(index int) error {
|
||||
if err := deleteFromSlice(&f.Categories, index); err != nil {
|
||||
return fmt.Errorf("error deleting category %v from entry %v: %v", index, f.ID.URI, err)
|
||||
// DeleteCategory deletes the Category from the Feed. It return an error.
|
||||
func (f *Feed) DeleteCategory(id int) error {
|
||||
if err := deleteFromSlice(&f.Categories, id); err != nil {
|
||||
return fmt.Errorf("error deleting category %v from entry %v: %v", id, f.ID.URI, err)
|
||||
}
|
||||
|
||||
f.Updated = NewDate(time.Now())
|
||||
@ -74,11 +73,10 @@ func (f *Feed) AddContributor(c *Person) {
|
||||
f.Updated = NewDate(time.Now())
|
||||
}
|
||||
|
||||
// DeleteContributor deletes the Person at index from the Feed. It return an
|
||||
// error.
|
||||
func (f *Feed) DeleteContributor(index int) error {
|
||||
if err := deleteFromSlice(&f.Contributors, index); err != nil {
|
||||
return fmt.Errorf("error deleting contributor %v from entry %v: %v", index, f.ID.URI, err)
|
||||
// DeleteContributor deletes the Person from the Feed. It return an error.
|
||||
func (f *Feed) DeleteContributor(id int) error {
|
||||
if err := deleteFromSlice(&f.Contributors, id); err != nil {
|
||||
return fmt.Errorf("error deleting contributor %v from entry %v: %v", id, f.ID.URI, err)
|
||||
}
|
||||
|
||||
f.Updated = NewDate(time.Now())
|
||||
@ -91,10 +89,10 @@ func (f *Feed) AddLink(l *Link) {
|
||||
f.Updated = NewDate(time.Now())
|
||||
}
|
||||
|
||||
// DeleteLink deletes the Link at index from the Feed. It return an error.
|
||||
func (f *Feed) DeleteLink(index int) error {
|
||||
if err := deleteFromSlice(&f.Links, index); err != nil {
|
||||
return fmt.Errorf("error deleting link %v from entry %v: %v", index, f.ID.URI, err)
|
||||
// DeleteLink deletes the Link from the Feed. It return an error.
|
||||
func (f *Feed) DeleteLink(id int) error {
|
||||
if err := deleteFromSlice(&f.Links, id); err != nil {
|
||||
return fmt.Errorf("error deleting link %v from entry %v: %v", id, f.ID.URI, err)
|
||||
}
|
||||
|
||||
f.Updated = NewDate(time.Now())
|
||||
@ -107,11 +105,10 @@ func (f *Feed) AddExtension(e *ExtensionElement) {
|
||||
f.Updated = NewDate(time.Now())
|
||||
}
|
||||
|
||||
// DeleteExtension deletes the Extension at index from the Feed. It return an
|
||||
// error.
|
||||
func (f *Feed) DeleteExtension(index int) error {
|
||||
if err := deleteFromSlice(&f.Extensions, index); err != nil {
|
||||
return fmt.Errorf("error deleting extension %v from entry %v: %v", index, f.ID.URI, err)
|
||||
// DeleteExtension deletes the Extension from the Feed. It return an error.
|
||||
func (f *Feed) DeleteExtension(id int) error {
|
||||
if err := deleteFromSlice(&f.Extensions, id); err != nil {
|
||||
return fmt.Errorf("error deleting extension %v from entry %v: %v", id, f.ID.URI, err)
|
||||
}
|
||||
|
||||
f.Updated = NewDate(time.Now())
|
||||
@ -124,10 +121,10 @@ func (f *Feed) AddEntry(e *Entry) {
|
||||
f.Updated = NewDate(time.Now())
|
||||
}
|
||||
|
||||
// DeleteEntry deletes the Entry at index from the Feed. It return an error.
|
||||
func (f *Feed) DeleteEntry(index int) error {
|
||||
if err := deleteFromSlice(&f.Entries, index); err != nil {
|
||||
return fmt.Errorf("error deleting entry %v from entry %v: %v", index, f.ID.URI, err)
|
||||
// DeleteEntry deletes the Entry from the Feed. It return an error.
|
||||
func (f *Feed) DeleteEntry(id int) error {
|
||||
if err := deleteFromSlice(&f.Entries, id); err != nil {
|
||||
return fmt.Errorf("error deleting entry %v from entry %v: %v", id, f.ID.URI, err)
|
||||
}
|
||||
|
||||
f.Updated = NewDate(time.Now())
|
||||
|
@ -26,11 +26,10 @@ func (p *Person) AddExtension(e *ExtensionElement) {
|
||||
addToSlice(&p.Extensions, e)
|
||||
}
|
||||
|
||||
// DeleteExtension deletes the Extension at index from the Person. It return an
|
||||
// error.
|
||||
func (p *Person) DeleteExtension(index int) error {
|
||||
if err := deleteFromSlice(&p.Extensions, index); err != nil {
|
||||
return fmt.Errorf("error deleting extension %v from person %v: %v", index, p, err)
|
||||
// DeleteExtension deletes the Extension from the Person. It return an error.
|
||||
func (p *Person) DeleteExtension(id int) error {
|
||||
if err := deleteFromSlice(&p.Extensions, id); err != nil {
|
||||
return fmt.Errorf("error deleting extension %v from person %v: %v", id, p, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
43
source.go
43
source.go
@ -33,10 +33,10 @@ func (s *Source) AddAuthor(p *Person) {
|
||||
addToSlice(&s.Authors, p)
|
||||
}
|
||||
|
||||
// DeleteAuthor deletes the Person at index from the Source. It return an error.
|
||||
func (s *Source) DeleteAuthor(index int) error {
|
||||
if err := deleteFromSlice(&s.Authors, index); err != nil {
|
||||
return fmt.Errorf("error deleting author %v from source %v: %v", index, s, err)
|
||||
// DeleteAuthor deletes the Person from the Source. It return an error.
|
||||
func (s *Source) DeleteAuthor(id int) error {
|
||||
if err := deleteFromSlice(&s.Authors, id); err != nil {
|
||||
return fmt.Errorf("error deleting author %v from source %v: %v", id, s, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -46,11 +46,10 @@ func (s *Source) AddCategory(c *Category) {
|
||||
addToSlice(&s.Categories, c)
|
||||
}
|
||||
|
||||
// DeleteCategory deletes the Category at index from the Source. It return an
|
||||
// error.
|
||||
func (s *Source) DeleteCategory(index int) error {
|
||||
if err := deleteFromSlice(&s.Categories, index); err != nil {
|
||||
return fmt.Errorf("error deleting category %v from source %v: %v", index, s, err)
|
||||
// DeleteCategory deletes the Category from the Source. It return an error.
|
||||
func (s *Source) DeleteCategory(id int) error {
|
||||
if err := deleteFromSlice(&s.Categories, id); err != nil {
|
||||
return fmt.Errorf("error deleting category %v from source %v: %v", id, s, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -60,11 +59,10 @@ func (s *Source) AddContributor(c *Person) {
|
||||
addToSlice(&s.Contributors, c)
|
||||
}
|
||||
|
||||
// DeleteContributor deletes the Person at index from the Source. It return an
|
||||
// error.
|
||||
func (s *Source) DeleteContributor(index int) error {
|
||||
if err := deleteFromSlice(&s.Contributors, index); err != nil {
|
||||
return fmt.Errorf("error deleting contributor %v from source %v: %v", index, s, err)
|
||||
// DeleteContributor deletes the Person from the Source. It return an error.
|
||||
func (s *Source) DeleteContributor(id int) error {
|
||||
if err := deleteFromSlice(&s.Contributors, id); err != nil {
|
||||
return fmt.Errorf("error deleting contributor %v from source %v: %v", id, s, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -74,10 +72,10 @@ func (s *Source) AddLink(l *Link) {
|
||||
addToSlice(&s.Links, l)
|
||||
}
|
||||
|
||||
// DeleteLink deletes the Link at index from the Source. It return an error.
|
||||
func (s *Source) DeleteLink(index int) error {
|
||||
if err := deleteFromSlice(&s.Links, index); err != nil {
|
||||
return fmt.Errorf("error deleting link %v from source %v: %v", index, s, err)
|
||||
// DeleteLink deletes the Link from the Source. It return an error.
|
||||
func (s *Source) DeleteLink(id int) error {
|
||||
if err := deleteFromSlice(&s.Links, id); err != nil {
|
||||
return fmt.Errorf("error deleting link %v from source %v: %v", id, s, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -87,11 +85,10 @@ func (s *Source) AddExtension(e *ExtensionElement) {
|
||||
addToSlice(&s.Extensions, e)
|
||||
}
|
||||
|
||||
// DeleteExtension deletes the Extension at index from the Source. It return an
|
||||
// error.
|
||||
func (s *Source) DeleteExtension(index int) error {
|
||||
if err := deleteFromSlice(&s.Extensions, index); err != nil {
|
||||
return fmt.Errorf("error deleting extension %v from source %v: %v", index, s, err)
|
||||
// DeleteExtension deletes the Extension from the Source. It return an error.
|
||||
func (s *Source) DeleteExtension(id int) error {
|
||||
if err := deleteFromSlice(&s.Extensions, id); err != nil {
|
||||
return fmt.Errorf("error deleting extension %v from source %v: %v", id, s, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user