-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
35 lines (30 loc) · 913 Bytes
/
types.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
package starlet
import "go.starlark.net/starlark"
// StringAnyMap type is a map of string to interface{} and is used to store global variables like StringDict of Starlark, but not a Starlark type.
type StringAnyMap map[string]interface{}
// Clone returns a copy of the data store. It returns an empty map if the current data store is nil.
func (d StringAnyMap) Clone() StringAnyMap {
clone := make(StringAnyMap)
for k, v := range d {
clone[k] = v
}
return clone
}
// Merge merges the given data store into the current data store. It does nothing if the current data store is nil.
func (d StringAnyMap) Merge(other StringAnyMap) {
if d == nil {
return
}
for k, v := range other {
d[k] = v
}
}
// MergeDict merges the given string dict into the current data store.
func (d StringAnyMap) MergeDict(other starlark.StringDict) {
if d == nil {
return
}
for k, v := range other {
d[k] = v
}
}