-
Notifications
You must be signed in to change notification settings - Fork 0
/
value.go
47 lines (38 loc) · 965 Bytes
/
value.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
40
41
42
43
44
45
46
47
package main
// Values represents a collection of values
type Values struct {
values map[string]Value
}
// Add a key/value to the collection
func (v *Values) Add(key string, value Value) {
v.values[key] = value
}
// Count returns number of items in collection
func (v Values) Count() int {
return len(v.values)
}
// Get returns a single value from the collection
func (v Values) Get(key string) Value {
return v.values[key]
}
// HasKey indicates if key exists in collection
func (v Values) HasKey(key string) bool {
_, ok := v.values[key]
return ok
}
// Iterate the collection value data
func (v Values) Iterate() map[string]Value {
return v.values
}
// Remove a key from the collection
func (v *Values) Remove(key string) {
delete(v.values, key)
}
// NewValues returns a new values map
func NewValues() *Values {
return &Values{
values: make(map[string]Value),
}
}
// Value represents the parsed value as stored in git notes
type Value string