FromStrings creates new labels from pairs of strings.
(ss ...string)
| 469 | |
| 470 | // FromStrings creates new labels from pairs of strings. |
| 471 | func FromStrings(ss ...string) Labels { |
| 472 | if len(ss)%2 != 0 { |
| 473 | panic("invalid number of strings") |
| 474 | } |
| 475 | ls := make([]Label, 0, len(ss)/2) |
| 476 | for i := 0; i < len(ss); i += 2 { |
| 477 | ls = append(ls, Label{Name: ss[i], Value: ss[i+1]}) |
| 478 | } |
| 479 | |
| 480 | return New(ls...) |
| 481 | } |
| 482 | |
| 483 | // Compare compares the two label sets. |
| 484 | // The result will be 0 if a==b, <0 if a < b, and >0 if a > b. |
searching dependent graphs…