-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.go
127 lines (103 loc) · 2.84 KB
/
action.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package uexec
// Action holds the first return item
type Action struct {
Values []interface{}
CallBackFunc interface{}
CallBackArgs []interface{}
CallBackValues interface{}
ErrCallBackValues interface{}
Err interface{}
}
// AddCallBack adds a callback function that can run on Exec errors
func (t Action) AddCallBack(callBackFunc interface{}, callBackArgs ...interface{}) Action {
t.CallBackFunc = callBackFunc
t.CallBackArgs = append(t.CallBackArgs, callBackArgs...)
return t
}
// CallBack function for running after an error has been caught
func (t Action) CallBack() Action {
switch fn := t.CallBackFunc.(type) {
case func(...interface{}) interface{}:
t.CallBackValues = fn(t.CallBackArgs...)
}
return t
}
// GetError returns the Err value
func (t Action) GetError(n int) error {
return t.Values[n].(error)
}
// Get Returns a value
func (t Action) Get(n int) interface{} {
return t.Values[n]
}
// Byte returns a value of type byte
func (t Action) Byte(n int) byte {
return t.Values[n].(byte)
}
// ByteS returns an array of type byte
func (t Action) ByteS(n int) []byte {
return t.Values[n].([]byte)
}
func (t Action) String(n int) string {
return t.Values[n].(string)
}
// StringS returns an array of strings
func (t Action) StringS(n int) []string {
return t.Values[n].([]string)
}
// Int returns a value of type int
func (t Action) Int(n int) int {
return t.Values[n].(int)
}
// Int8 returns a value of type int8
func (t Action) Int8(n int) int8 {
return t.Values[n].(int8)
}
// Int16 returns a value of type int16
func (t Action) Int16(n int) int16 {
return t.Values[n].(int16)
}
// Int32 returns a value of type int32
func (t Action) Int32(n int) int32 {
return t.Values[n].(int32)
}
// Int64 returns a value of type int64
func (t Action) Int64(n int) int64 {
return t.Values[n].(int64)
}
// IntS returns an array of type int
func (t Action) IntS(n int) []int {
return t.Values[n].([]int)
}
// Int8S returns an array of type int8
func (t Action) Int8S(n int) []int8 {
return t.Values[n].([]int8)
}
// Int16S returns an array of type int16
func (t Action) Int16S(n int) []int16 {
return t.Values[n].([]int16)
}
// Int32S returns an array of type int32
func (t Action) Int32S(n int) []int32 {
return t.Values[n].([]int32)
}
// Int64S returns an array of type int64
func (t Action) Int64S(n int) []int64 {
return t.Values[n].([]int64)
}
// Float32 returns a value of type float32
func (t Action) Float32(n int) float32 {
return t.Values[n].(float32)
}
// Float64 returns a value of type float64
func (t Action) Float64(n int) float64 {
return t.Values[n].(float64)
}
// Float32S returns an array of type float32
func (t Action) Float32S(n int) []float32 {
return t.Values[n].([]float32)
}
// Float64S returns an array of type float64
func (t Action) Float64S(n int) []float64 {
return t.Values[n].([]float64)
}