Files
renovate-sh-app[bot]GitHubrenovate-sh-app[bot] <219655108+renovate-sh-app[bot]@users.noreply.github.com>
e0378dbf74 chore(deps): update module github.com/expr-lang/expr to v1.17.7 [security] (#6092)
| datasource | package                   | from    | to      |
| ---------- | ------------------------- | ------- | ------- |
| go         | github.com/expr-lang/expr | v1.17.6 | v1.17.7 |

Signed-off-by: renovate-sh-app[bot] <219655108+renovate-sh-app[bot]@users.noreply.github.com>
Co-authored-by: renovate-sh-app[bot] <219655108+renovate-sh-app[bot]@users.noreply.github.com>
2025-12-17 14:36:07 +00:00

57 lines
848 B
Go

package deref
import (
"fmt"
"reflect"
)
func Interface(p any) any {
if p == nil {
return nil
}
v := reflect.ValueOf(p)
for v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface {
if v.IsNil() {
return nil
}
v = v.Elem()
}
if v.IsValid() {
return v.Interface()
}
panic(fmt.Sprintf("cannot dereference %v", p))
}
func Type(t reflect.Type) reflect.Type {
if t == nil {
return nil
}
for t.Kind() == reflect.Ptr {
t = t.Elem()
}
return t
}
func Value(v reflect.Value) reflect.Value {
for v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface {
if v.IsNil() {
return v
}
v = v.Elem()
}
return v
}
func TypeKind(t reflect.Type, k reflect.Kind) (_ reflect.Type, _ reflect.Kind, changed bool) {
for k == reflect.Pointer {
changed = true
t = t.Elem()
k = t.Kind()
}
return t, k, changed
}