fix: panic when passing pointer to pointer as param
This commit is contained in:
parent
be738c8546
commit
5f175bf3fc
@ -431,7 +431,7 @@ func strctVal(s interface{}) reflect.Value {
|
|||||||
v := reflect.ValueOf(s)
|
v := reflect.ValueOf(s)
|
||||||
|
|
||||||
// if pointer get the underlying element≤
|
// if pointer get the underlying element≤
|
||||||
if v.Kind() == reflect.Ptr {
|
for v.Kind() == reflect.Ptr {
|
||||||
v = v.Elem()
|
v = v.Elem()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1376,3 +1376,24 @@ func TestMap_InterfaceValue(t *testing.T) {
|
|||||||
t.Errorf("Value does not match expected: %q != %q", s["A"], expected)
|
t.Errorf("Value does not match expected: %q != %q", s["A"], expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPointer2Pointer(t *testing.T) {
|
||||||
|
defer func() {
|
||||||
|
err := recover()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("err %+v\n", err)
|
||||||
|
t.Error("Internal nil pointer should not panic")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
a := &Animal{
|
||||||
|
Name: "Fluff",
|
||||||
|
Age: 4,
|
||||||
|
}
|
||||||
|
_ = Map(&a)
|
||||||
|
|
||||||
|
b := &a
|
||||||
|
_ = Map(&b)
|
||||||
|
|
||||||
|
c := &b
|
||||||
|
_ = Map(&c)
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user