mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-12 12:50:28 +08:00
fix(nat): panic on nil endpoint
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package helper
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@@ -30,3 +31,11 @@ func StringToBytes(s string) (b []byte) {
|
||||
bh.cap = sh.len
|
||||
return b
|
||||
}
|
||||
|
||||
func IsNilInterface(x any) bool {
|
||||
return x == nil || reflect.ValueOf(x).IsZero()
|
||||
}
|
||||
|
||||
func IsNonNilInterface(x any) bool {
|
||||
return !IsNilInterface(x)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user