SetAttrs2 sets multiple attributes and returns whether there were any changes. The provided keyval should be an even number of alternating key/value pairs to set.
(keyval ...string)
| 1513 | // any changes. The provided keyval should be an even number of |
| 1514 | // alternating key/value pairs to set. |
| 1515 | func (o *Object) SetAttrs2(keyval ...string) (changes bool, err error) { |
| 1516 | if len(keyval)%2 == 1 { |
| 1517 | panic("importer.SetAttrs: odd argument count") |
| 1518 | } |
| 1519 | |
| 1520 | g := syncutil.Group{} |
| 1521 | for i := 0; i < len(keyval); i += 2 { |
| 1522 | key, val := keyval[i], keyval[i+1] |
| 1523 | if val != o.Attr(key) { |
| 1524 | changes = true |
| 1525 | g.Go(func() error { |
| 1526 | return o.SetAttr(key, val) |
| 1527 | }) |
| 1528 | } |
| 1529 | } |
| 1530 | return changes, g.Err() |
| 1531 | } |
| 1532 | |
| 1533 | // SetAttrValues sets multi-valued attribute. |
| 1534 | func (o *Object) SetAttrValues(key string, attrs []string) error { |
no test coverage detected