1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 21:02:27 +08:00

fix: fix issue #162

This commit is contained in:
dudaodong
2024-01-29 11:00:50 +08:00
parent a630a7cda9
commit 38920e3be6
4 changed files with 67 additions and 3 deletions

View File

@@ -4,7 +4,9 @@
// Package pointer contains some util functions to operate go pointer.
package pointer
import "reflect"
import (
"reflect"
)
// Of returns a pointer to the value `v`.
// Play: https://go.dev/play/p/HFd70x4DrMj
@@ -47,5 +49,10 @@ func ExtractPointer(value any) any {
if t.Kind() != reflect.Pointer {
return value
}
return ExtractPointer(v.Elem().Interface())
if v.Elem().IsValid() {
return ExtractPointer(v.Elem().Interface())
}
return nil
}