stream/mts/meta/meta.go: updated meta.NewWith so that it just uses meta.New, and now ti can add an abitrary number of things to the map. It also overwrites keys that have been repeated

This commit is contained in:
saxon 2019-02-06 12:16:44 +10:30
parent 2b7ab27763
commit 57d1dba2fb
1 changed files with 11 additions and 11 deletions

View File

@ -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.