diff options
author | Matthew Heon <matthew.heon@pm.me> | 2019-01-08 13:56:47 -0500 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-01-10 15:48:09 -0500 |
commit | 1b761dbb02afc52f97a50af4b073a756c5cc6820 (patch) | |
tree | 2cfd5529fdffd98bbfa71b01ede72cf33bc403ce /vendor/github.com/modern-go/reflect2/safe_field.go | |
parent | 07f3b147f1619b234cad0fda3d7556c1f05e7f11 (diff) | |
download | podman-1b761dbb02afc52f97a50af4b073a756c5cc6820.tar.gz podman-1b761dbb02afc52f97a50af4b073a756c5cc6820.tar.bz2 podman-1b761dbb02afc52f97a50af4b073a756c5cc6820.zip |
Update json-iterator vendor to v1.1.5
We already have it vendored for a Kube package we import, but we
want a more recent version with additional bugfixes over the 1.0
release we originally had.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'vendor/github.com/modern-go/reflect2/safe_field.go')
-rw-r--r-- | vendor/github.com/modern-go/reflect2/safe_field.go | 58 |
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") +} |