aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/modern-go/reflect2/safe_field.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/modern-go/reflect2/safe_field.go')
-rw-r--r--vendor/github.com/modern-go/reflect2/safe_field.go58
1 files changed, 0 insertions, 58 deletions
diff --git a/vendor/github.com/modern-go/reflect2/safe_field.go b/vendor/github.com/modern-go/reflect2/safe_field.go
deleted file mode 100644
index d4ba1f4..0000000
--- a/vendor/github.com/modern-go/reflect2/safe_field.go
+++ /dev/null
@@ -1,58 +0,0 @@
1package reflect2
2
3import (
4 "reflect"
5 "unsafe"
6)
7
8type safeField struct {
9 reflect.StructField
10}
11
12func (field *safeField) Offset() uintptr {
13 return field.StructField.Offset
14}
15
16func (field *safeField) Name() string {
17 return field.StructField.Name
18}
19
20func (field *safeField) PkgPath() string {
21 return field.StructField.PkgPath
22}
23
24func (field *safeField) Type() Type {
25 panic("not implemented")
26}
27
28func (field *safeField) Tag() reflect.StructTag {
29 return field.StructField.Tag
30}
31
32func (field *safeField) Index() []int {
33 return field.StructField.Index
34}
35
36func (field *safeField) Anonymous() bool {
37 return field.StructField.Anonymous
38}
39
40func (field *safeField) Set(obj interface{}, value interface{}) {
41 val := reflect.ValueOf(obj).Elem()
42 val.FieldByIndex(field.Index()).Set(reflect.ValueOf(value).Elem())
43}
44
45func (field *safeField) UnsafeSet(obj unsafe.Pointer, value unsafe.Pointer) {
46 panic("unsafe operation is not supported")
47}
48
49func (field *safeField) Get(obj interface{}) interface{} {
50 val := reflect.ValueOf(obj).Elem().FieldByIndex(field.Index())
51 ptr := reflect.New(val.Type())
52 ptr.Elem().Set(val)
53 return ptr.Interface()
54}
55
56func (field *safeField) UnsafeGet(obj unsafe.Pointer) unsafe.Pointer {
57 panic("does not support unsafe operation")
58}