Add comments to generic functions
This commit is contained in:
parent
c0f5306715
commit
b6b8970810
3
atom.go
3
atom.go
@ -16,6 +16,7 @@ type Countable interface {
|
||||
*xml.Attr | *Person | *Category | *Link | *ExtensionElement | *Entry
|
||||
}
|
||||
|
||||
// addToSlice adds a Countable to to a *[]Countable
|
||||
func addToSlice[C Countable](slice *[]C, countable C) {
|
||||
if *slice == nil {
|
||||
*slice = make([]C, 0)
|
||||
@ -23,6 +24,8 @@ func addToSlice[C Countable](slice *[]C, countable C) {
|
||||
*slice = append(*slice, countable)
|
||||
}
|
||||
|
||||
// deleteFromSlice deletes the Countable with the index from the *[]Countable.
|
||||
// It return an error.
|
||||
func deleteFromSlice[C Countable](slice *[]C, id int) error {
|
||||
length := len(*slice)
|
||||
if id > length {
|
||||
|
Loading…
x
Reference in New Issue
Block a user