Merge adds the contents of the second set of Annotations to the first, modifying the first in-place, and returns the merged first Annotations for convenience.
(aa Annotations)
| 56 | // Merge adds the contents of the second set of Annotations to the first, modifying |
| 57 | // the first in-place, and returns the merged first Annotations for convenience. |
| 58 | func (a *Annotations) Merge(aa Annotations) Annotations { |
| 59 | if *a == nil { |
| 60 | if aa == nil { |
| 61 | return nil |
| 62 | } |
| 63 | *a = Annotations{} |
| 64 | } |
| 65 | for key, val := range aa { |
| 66 | if prevVal, exists := (*a)[key]; exists { |
| 67 | var anErr annoError |
| 68 | if errors.As(val, &anErr) { |
| 69 | val = anErr.Merge(prevVal) |
| 70 | } |
| 71 | } |
| 72 | (*a)[key] = val |
| 73 | } |
| 74 | return *a |
| 75 | } |
| 76 | |
| 77 | // AsErrors is a convenience function to return the annotations map as a slice |
| 78 | // of errors. |