MCPcopy
hub / github.com/TomWright/dasel / Set

Method Set

model/value_set.go:9–70  ·  view source on GitHub ↗

Set sets the value of the value.

(newValue *Value)

Source from the content-addressed store, hash-verified

7
8// Set sets the value of the value.
9func (v *Value) Set(newValue *Value) error {
10 if v.isDaselValue() {
11 dv, err := v.daselValue()
12 if err != nil {
13 return err
14 }
15 return dv.Set(newValue)
16 }
17
18 if v.setFn != nil {
19 return v.setFn(newValue)
20 }
21
22 a, err := v.UnpackUntilAddressable()
23 if err != nil {
24 return err
25 }
26
27 b := newValue.UnpackKinds(reflect.Pointer)
28 if a.Kind() == b.Kind() {
29 a.value.Set(b.value)
30 return nil
31 }
32
33 b = newValue.UnpackKinds(reflect.Pointer, reflect.Interface)
34 if a.Kind() == b.Kind() {
35 a.value.Set(b.value)
36 return nil
37 }
38
39 // These are commented out because I don't think they are needed.
40
41 //if a.Kind() == newValue.Kind() {
42 // a.Value.Set(newValue.Value)
43 // return nil
44 //}
45
46 //b = newValue.UnpackKinds(reflect.Interface)
47 //if a.Kind() == b.Kind() {
48 // a.Value.Set(b.Value)
49 // return nil
50 //}
51
52 //b = newValue.UnpackKinds(reflect.Pointer, reflect.Interface)
53 //if a.Kind() == b.Kind() {
54 // a.Value.Set(b.Value)
55 // return nil
56 //}
57
58 //b, err = newValue.UnpackUntilAddressable()
59 //if err != nil {
60 // return err
61 //}
62 //if a.Kind() == b.Kind() {
63 // a.Value.Set(b.Value)
64 // return nil
65 //}
66

Callers 15

ModifyFunction · 0.45
NewValueFunction · 0.45
TestMapFunction · 0.45
TestMapCopyFunction · 0.45
TestMapKeyExistsFunction · 0.45
TestMapKeyValuesFunction · 0.45
NewSliceValueFunction · 0.45
AppendMethod · 0.45
SetSliceIndexMethod · 0.45
SetMapKeyMethod · 0.45
GetMapKeyMethod · 0.45
runMethod · 0.45

Calls 6

isDaselValueMethod · 0.95
daselValueMethod · 0.95
TypeMethod · 0.95
UnpackKindsMethod · 0.80
KindMethod · 0.80

Tested by 15

TestMapFunction · 0.36
TestMapCopyFunction · 0.36
TestMapKeyExistsFunction · 0.36
TestMapKeyValuesFunction · 0.36
runMethod · 0.36
TestValue_CopyFunction · 0.36
TestValue_Set_SetFnFunction · 0.36
TestValue_Set_NestedFunction · 0.36
TestValue_MapLenFunction · 0.36
TestValue_StringFunction · 0.36
TestUnaryFunction · 0.36
TestAnyExprFunction · 0.36