mirror of
https://github.com/golang/go
synced 2024-11-24 14:40:15 -07:00
use single reflect
This commit is contained in:
parent
3a8a7cac38
commit
35c8f700a7
@ -48,11 +48,11 @@ func signum(sig os.Signal) int {
|
|||||||
// as they might be defined in external packages like golang.org/x/sys.
|
// as they might be defined in external packages like golang.org/x/sys.
|
||||||
// Since we cannot import those platform-specific signal types,
|
// Since we cannot import those platform-specific signal types,
|
||||||
// reflection allows us to handle them in a generic way.
|
// reflection allows us to handle them in a generic way.
|
||||||
kind := reflect.TypeOf(sig).Kind()
|
v := reflect.ValueOf(sig)
|
||||||
switch kind {
|
switch v.Kind() {
|
||||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||||
// Extract the integer value from sig and validate it.
|
// Extract the integer value from sig and validate it.
|
||||||
i := int(reflect.ValueOf(sig).Int())
|
i := int(v.Int())
|
||||||
if i < 0 || i >= numSig {
|
if i < 0 || i >= numSig {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user