mirror of https://bitbucket.org/ausocean/av.git
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:
parent
2b7ab27763
commit
57d1dba2fb
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue