summaryrefslogtreecommitdiff
path: root/vendor/github.com/modern-go/reflect2/safe_field.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-01-11 02:25:41 -0800
committerGitHub <noreply@github.com>2019-01-11 02:25:41 -0800
commit26f2b7debde313af4a5ae39727c66a3f8fd59be4 (patch)
tree1ab2968feabc60768ac04c7f832ddfb93f97e3ad /vendor/github.com/modern-go/reflect2/safe_field.go
parent36d96c19f947aeac2675afe64a3b482e54f9e4c4 (diff)
parent3966d3bf4e6be2975c330af64ce6ba86b4eeabe0 (diff)
downloadpodman-26f2b7debde313af4a5ae39727c66a3f8fd59be4.tar.gz
podman-26f2b7debde313af4a5ae39727c66a3f8fd59be4.tar.bz2
podman-26f2b7debde313af4a5ae39727c66a3f8fd59be4.zip
Merge pull request #2105 from mheon/jsoniter
Use jsoniter instead of easyjson
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, 58 insertions, 0 deletions
diff --git a/vendor/github.com/modern-go/reflect2/safe_field.go b/vendor/github.com/modern-go/reflect2/safe_field.go
new file mode 100644
index 000000000..d4ba1f4f8
--- /dev/null
+++ b/vendor/github.com/modern-go/reflect2/safe_field.go
@@ -0,0 +1,58 @@
+package reflect2
+
+import (
+ "reflect"
+ "unsafe"
+)
+
+type safeField struct {
+ reflect.StructField
+}
+
+func (field *safeField) Offset() uintptr {
+ return field.StructField.Offset
+}
+
+func (field *safeField) Name() string {
+ return field.StructField.Name
+}
+
+func (field *safeField) PkgPath() string {
+ return field.StructField.PkgPath
+}
+
+func (field *safeField) Type() Type {
+ panic("not implemented")
+}
+
+func (field *safeField) Tag() reflect.StructTag {
+ return field.StructField.Tag
+}
+
+func (field *safeField) Index() []int {
+ return field.StructField.Index
+}
+
+func (field *safeField) Anonymous() bool {
+ return field.StructField.Anonymous
+}
+
+func (field *safeField) Set(obj interface{}, value interface{}) {
+ val := reflect.ValueOf(obj).Elem()
+ val.FieldByIndex(field.Index()).Set(reflect.ValueOf(value).Elem())
+}
+
+func (field *safeField) UnsafeSet(obj unsafe.Pointer, value unsafe.Pointer) {
+ panic("unsafe operation is not supported")
+}
+
+func (field *safeField) Get(obj interface{}) interface{} {
+ val := reflect.ValueOf(obj).Elem().FieldByIndex(field.Index())
+ ptr := reflect.New(val.Type())
+ ptr.Elem().Set(val)
+ return ptr.Interface()
+}
+
+func (field *safeField) UnsafeGet(obj unsafe.Pointer) unsafe.Pointer {
+ panic("does not support unsafe operation")
+}