refactor: avoid calling strings.ToLower twice (#3433)

This commit is contained in:
lgbgbl 2022-12-22 23:17:19 +08:00 committed by GitHub
parent 2285aa5430
commit 297b664cf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,7 +62,9 @@ func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc {
if ne, ok := err.(*net.OpError); ok { if ne, ok := err.(*net.OpError); ok {
var se *os.SyscallError var se *os.SyscallError
if errors.As(ne, &se) { if errors.As(ne, &se) {
if strings.Contains(strings.ToLower(se.Error()), "broken pipe") || strings.Contains(strings.ToLower(se.Error()), "connection reset by peer") { seStr := strings.ToLower(se.Error())
if strings.Contains(seStr, "broken pipe") ||
strings.Contains(seStr, "connection reset by peer") {
brokenPipe = true brokenPipe = true
} }
} }