-
Notifications
You must be signed in to change notification settings - Fork 0
/
metadata.go
39 lines (34 loc) · 860 Bytes
/
metadata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package config
// Metadata holds arbitrary strings as key - value pairs
type Metadata map[string]string
// Get returns the value of the given key. If the key does not exist in the
// metadata, a blank string will be returned
func (m Metadata) Get(key string) string {
return m[key]
}
// Has returns true if the metadata contains the key. Keys with blank values
// will return true.
func (m Metadata) Has(key string) (exists bool) {
_, exists = m[key]
return
}
// Keys returns all keys of the metadata
func (m Metadata) Keys() []string {
keys := make([]string, len(m))
var i int
for key, _ := range m {
keys[i] = key
i += 1
}
return keys
}
// Values returns all values of the metadata
func (m Metadata) Values() []string {
values := make([]string, len(m))
var i int
for _, value := range m {
values[i] = value
i += 1
}
return values
}