From 6855244424cd8370a61cdc337d3102625c135408 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 18 Feb 2020 15:45:48 +1030 Subject: [PATCH] mts/meta: created NewFromMap method --- container/mts/meta/meta.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/container/mts/meta/meta.go b/container/mts/meta/meta.go index 0e67aa96..8bcdf464 100644 --- a/container/mts/meta/meta.go +++ b/container/mts/meta/meta.go @@ -90,6 +90,17 @@ func NewWith(data [][2]string) *Data { return m } +// NewFromMap creates a meta.Data from a map. +func NewFromMap(data map[string]string) *Data { + m := New() + m.order = make([]string, 0, len(data)) + for k, v := range data { + m.data[k] = v + m.order = append(m.order, k) + } + return m +} + // Add adds metadata with key and val. func (m *Data) Add(key, val string) { m.mu.Lock()