iop/packages/go/metadata/metadata.go

30 lines
449 B
Go

package metadata
// M is a string key-value metadata map used throughout IOP.
type M map[string]string
func (m M) Get(key string) string {
if m == nil {
return ""
}
return m[key]
}
func (m M) Set(key, value string) M {
if m == nil {
m = make(M)
}
m[key] = value
return m
}
func (m M) Merge(other M) M {
out := make(M, len(m)+len(other))
for k, v := range m {
out[k] = v
}
for k, v := range other {
out[k] = v
}
return out
}