-
Notifications
You must be signed in to change notification settings - Fork 2
/
context_utils.go
61 lines (46 loc) · 1.12 KB
/
context_utils.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package neocortex
func (c *Context) SetContextVariable(name string, value interface{}) {
if c.Variables == nil {
c.Variables = map[string]interface{}{}
}
c.Variables[name] = value
}
func (c *Context) DeleteContextVariable(name string, value interface{}) {
if c.Variables == nil {
c.Variables = map[string]interface{}{}
}
delete(c.Variables, name)
}
func (c *Context) GetStringContextVariable(name string, _default string) string {
if c.Variables == nil {
c.Variables = map[string]interface{}{}
return _default
}
value, isOk := c.Variables[name].(string)
if !isOk {
return _default
}
return value
}
func (c *Context) GetIntContextVariable(name string, _default int) int {
if c.Variables == nil {
c.Variables = map[string]interface{}{}
return _default
}
value, isOk := c.Variables[name].(int)
if !isOk {
return _default
}
return value
}
func (c *Context) GetFloat64ContextVariable(name string, _default float64) float64 {
if c.Variables == nil {
c.Variables = map[string]interface{}{}
return _default
}
value, isOk := c.Variables[name].(float64)
if !isOk {
return _default
}
return value
}