mirror of
https://github.com/smallnest/rpcx.git
synced 2025-09-26 20:21:14 +08:00
code opt: refactor to use reflect.TypeFor
This commit is contained in:
@@ -16,8 +16,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
typeOfError = reflect.TypeOf((*error)(nil)).Elem()
|
||||
typeOfContext = reflect.TypeOf((*context.Context)(nil)).Elem()
|
||||
typeOfError = reflect.TypeFor[error]()
|
||||
typeOfContext = reflect.TypeFor[context.Context]()
|
||||
)
|
||||
|
||||
// ServiceInfo service info.
|
||||
|
@@ -35,10 +35,10 @@ func (e RpcServiceInternalError) String() string {
|
||||
|
||||
// Precompute the reflect type for error. Can't use error directly
|
||||
// because Typeof takes an empty interface value. This is annoying.
|
||||
var typeOfError = reflect.TypeOf((*error)(nil)).Elem()
|
||||
var typeOfError = reflect.TypeFor[error]()
|
||||
|
||||
// Precompute the reflect type for context.
|
||||
var typeOfContext = reflect.TypeOf((*context.Context)(nil)).Elem()
|
||||
var typeOfContext = reflect.TypeFor[context.Context]()
|
||||
|
||||
type methodType struct {
|
||||
sync.Mutex // protects counters
|
||||
|
Reference in New Issue
Block a user