Delete removes the attribute with the given name.
(name Name)
| 77 | |
| 78 | // Delete removes the attribute with the given name. |
| 79 | func (a *Attributes) Delete(name Name) { |
| 80 | // If attribute does not exist, nothing to do |
| 81 | attr, exists := a.m[name] |
| 82 | if !exists { |
| 83 | return |
| 84 | } |
| 85 | |
| 86 | // Remove from map |
| 87 | delete(a.m, name) |
| 88 | |
| 89 | // Remove from slice |
| 90 | if idx := slices.Index(a.s, attr); idx != -1 { |
| 91 | a.s = slices.Delete(a.s, idx, idx+1) |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | // DeleteByString is like Delete but accepts a string name. |
| 96 | func (a *Attributes) DeleteByString(name string) { |