Skip to content

Commit

Permalink
refactor: avoid calling strings.ToLower twice
Browse files Browse the repository at this point in the history
  • Loading branch information
lgbgbl committed Dec 11, 2022
1 parent cc367f9 commit 2a8c7e1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc {
if ne, ok := err.(*net.OpError); ok {
var se *os.SyscallError
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
}
}
Expand Down

0 comments on commit 2a8c7e1

Please sign in to comment.