From d5b9529e22195bb80a8002f8844ce7d7815e0cf1 Mon Sep 17 00:00:00 2001 From: Yoshiyuki Mineo Date: Wed, 1 May 2024 00:42:29 +0900 Subject: [PATCH] Do refactoring --- v2/gobreaker.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/v2/gobreaker.go b/v2/gobreaker.go index 2f77a93..c0382d1 100644 --- a/v2/gobreaker.go +++ b/v2/gobreaker.go @@ -226,11 +226,10 @@ func (cb *CircuitBreaker[T]) Counts() Counts { // If a panic occurs in the request, the CircuitBreaker handles it as an error // and causes the same panic again. func (cb *CircuitBreaker[T]) Execute(req func() (T, error)) (T, error) { - var zero T - generation, err := cb.beforeRequest() if err != nil { - return zero, err + var defaultValue T + return defaultValue, err } defer func() {