MCPcopy
hub / github.com/perkeep/perkeep / SetAttrs2

Method SetAttrs2

pkg/importer/importer.go:1515–1531  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1513// any changes. The provided keyval should be an even number of
1514// alternating key/value pairs to set.
1515func (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.
1534func (o *Object) SetAttrValues(key string, attrs []string) error {

Callers 6

SetAttrsMethod · 0.95
importTweetMethod · 0.80
importBookmarkMethod · 0.80
importHighlightMethod · 0.80
importAlbumMethod · 0.80
importStatusMethod · 0.80

Calls 3

AttrMethod · 0.95
SetAttrMethod · 0.95
ErrMethod · 0.45

Tested by

no test coverage detected