aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/modern-go/reflect2/safe_field.go
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2023-12-29 21:31:53 +0100
committerLibravatar Rutger Broekhoff2023-12-29 21:31:53 +0100
commit404aeae4545d2426c089a5f8d5e82dae56f5212b (patch)
tree2d84e00af272b39fc04f3795ae06bc48970e57b5 /vendor/github.com/modern-go/reflect2/safe_field.go
parent209d8b0187ed025dec9ac149ebcced3462877bff (diff)
downloadgitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz
gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip
Make Nix builds work
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 0000000..d4ba1f4
--- /dev/null
+++ b/vendor/github.com/modern-go/reflect2/safe_field.go
@@ -0,0 +1,58 @@
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}