Attr returns the object's attribute value for the provided attr, or the empty string if unset. To distinguish between unset, an empty string, or multiple attribute values, use Attrs.
(attr string)
| 1426 | // or the empty string if unset. To distinguish between unset, |
| 1427 | // an empty string, or multiple attribute values, use Attrs. |
| 1428 | func (o *Object) Attr(attr string) string { |
| 1429 | o.mu.RLock() |
| 1430 | defer o.mu.RUnlock() |
| 1431 | if v := o.attr[attr]; len(v) > 0 { |
| 1432 | return v[0] |
| 1433 | } |
| 1434 | return "" |
| 1435 | } |
| 1436 | |
| 1437 | // Attrs returns the attribute values for the provided attr. |
| 1438 | func (o *Object) Attrs(attr string) []string { |