Skip to content

Commit 13f0eae

Browse files
committed
core: Loc returns uintptr for addressables
1 parent f471cfa commit 13f0eae

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

intra/core/closer.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,17 @@ func CloseOp(c io.Closer, op CloserOp) {
168168
}
169169
}
170170

171+
func Loc(x any) uintptr {
172+
v := reflect.ValueOf(x)
173+
k := v.Kind()
174+
switch k {
175+
// [Chan], [Func], [Map], [Pointer], [Slice], [String] or [UnsafePointer]
176+
case reflect.Pointer, reflect.UnsafePointer, reflect.String, reflect.Chan, reflect.Func, reflect.Map, reflect.Slice:
177+
return v.Pointer()
178+
}
179+
return 0
180+
}
181+
171182
// may panic or return false if x is not addressable
172183
func IsNotNil(x any) bool {
173184
return !IsNil(x)

0 commit comments

Comments
 (0)