-
Notifications
You must be signed in to change notification settings - Fork 1
/
interfacing.go
37 lines (32 loc) · 866 Bytes
/
interfacing.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
package refutil
// InterfaceOrNil will either return interface or
// nil if interface cannot be obtained
func (v Value) InterfaceOrNil() interface{} {
if !v.Value.IsValid() {
return nil
}
// if !v.Value.CanInterface() {
// return nil
// }
return v.Value.Interface()
}
// CanInterface returns whether value can interface
func (v Value) CanInterface() bool {
if !v.Value.IsValid() {
return false
}
return v.Value.CanInterface()
}
// CanInterface returns whether value can interface
func (v Data) CanInterface() bool {
return v.Value().CanInterface()
}
// Interface returns actual data originally inserted
func (v Data) Interface() interface{} {
return v.Value().Interface()
}
// InterfaceOrNil will either return interface or
// nil if interface cannot be obtained
func (v Data) InterfaceOrNil() interface{} {
return v.Value().InterfaceOrNil()
}