mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-09 08:32:26 -04:00
FromMap(), sorts and returns instead of calling New() (#433)
Signed-off-by: nilsocket <nilsocket@gmail.com>
This commit is contained in:
parent
171fc4ab5d
commit
80981a6aac
1 changed files with 4 additions and 2 deletions
|
|
@ -117,11 +117,13 @@ func New(ls ...Label) Labels {
|
|||
|
||||
// FromMap returns new sorted Labels from the given map.
|
||||
func FromMap(m map[string]string) Labels {
|
||||
l := make([]Label, 0, len(m))
|
||||
l := make(Labels, 0, len(m))
|
||||
for k, v := range m {
|
||||
l = append(l, Label{Name: k, Value: v})
|
||||
}
|
||||
return New(l...)
|
||||
sort.Sort(l)
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
// FromStrings creates new labels from pairs of strings.
|
||||
|
|
|
|||
Loading…
Reference in a new issue