chore: change interface{} to any (#2818)

* chore: change interface{} to any

* chore: update goctl version to 1.5.0

* chore: update goctl deps
This commit is contained in:
Kevin Wan
2023-01-24 16:32:02 +08:00
committed by GitHub
parent 7e0ac77139
commit ae87114282
221 changed files with 1910 additions and 2207 deletions

View File

@@ -11,9 +11,9 @@ import (
)
// StreamRecoverInterceptor catches panics in processing stream requests and recovers.
func StreamRecoverInterceptor(svr interface{}, stream grpc.ServerStream, _ *grpc.StreamServerInfo,
func StreamRecoverInterceptor(svr any, stream grpc.ServerStream, _ *grpc.StreamServerInfo,
handler grpc.StreamHandler) (err error) {
defer handleCrash(func(r interface{}) {
defer handleCrash(func(r any) {
err = toPanicError(r)
})
@@ -21,22 +21,22 @@ func StreamRecoverInterceptor(svr interface{}, stream grpc.ServerStream, _ *grpc
}
// UnaryRecoverInterceptor catches panics in processing unary requests and recovers.
func UnaryRecoverInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (resp interface{}, err error) {
defer handleCrash(func(r interface{}) {
func UnaryRecoverInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (resp any, err error) {
defer handleCrash(func(r any) {
err = toPanicError(r)
})
return handler(ctx, req)
}
func handleCrash(handler func(interface{})) {
func handleCrash(handler func(any)) {
if r := recover(); r != nil {
handler(r)
}
}
func toPanicError(r interface{}) error {
func toPanicError(r any) error {
logx.Errorf("%+v\n\n%s", r, debug.Stack())
return status.Errorf(codes.Internal, "panic: %v", r)
}