diff --git a/stream/mts/meta/meta.go b/stream/mts/meta/meta.go index 97725252..a2d56e1a 100644 --- a/stream/mts/meta/meta.go +++ b/stream/mts/meta/meta.go @@ -76,18 +76,18 @@ func New() *Data { } } -func NewWith(key, data string) *Data { - meta := &Data{ - data: make(map[string]string), - enc: []byte{ - 0x00, // Reserved byte - (majVer << 4) | minVer, // MS and LS versions - 0x00, // Data len byte1 - 0x00, // Data len byte2 - }, +// NewWith creates a meta.Data and fills map with initial data given. If there +// is repeated key, then the latter overwrites the prior. +func NewWith(data [][2]string) *Data { + m := New() + m.order = make([]string, 0, len(data)) + for _, d := range data { + if _, exists := m.data[d[0]]; !exists { + m.order = append(m.order, d[0]) + } + m.data[d[0]] = d[1] } - meta.Add(key, data) - return meta + return m } // Add adds metadata with key and val.