RenameAttribute changes the attribute named fromName to toName. Takes no action if fromName is missing or there is already a conflicting attribute called toName. Returns true if the rename succeeded.
(fromName, toName string)
| 109 | // |
| 110 | // Returns true if the rename succeeded. |
| 111 | func (b *Body) RenameAttribute(fromName, toName string) bool { |
| 112 | attr := b.GetAttribute(fromName) |
| 113 | conflictingAttr := b.GetAttribute(toName) |
| 114 | if attr == nil || conflictingAttr != nil { |
| 115 | return false |
| 116 | } |
| 117 | attr.setName(toName) |
| 118 | return true |
| 119 | } |
| 120 | |
| 121 | // FirstMatchingBlock returns a first matching block from the body that has the |
| 122 | // given name and labels or returns nil if there is currently no matching |