From 5b0c7191ef6d49e33f1fe0bbefe252363bcd9ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=81=E6=B5=A9=2010284789?= Date: Mon, 24 May 2021 07:15:36 +0000 Subject: [PATCH] simplify returning boolean expression in staging/src/k8s.io/client-go/tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刁浩 10284789 Kubernetes-commit: 9173414da6d1c70436b256d6068e3737a7434f6a --- tools/cache/fifo.go | 5 +---- tools/cache/heap.go | 5 +---- tools/clientcmd/config.go | 6 +----- tools/record/util/util.go | 6 +----- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/tools/cache/fifo.go b/tools/cache/fifo.go index edb2c8ed..f82bf22d 100644 --- a/tools/cache/fifo.go +++ b/tools/cache/fifo.go @@ -263,10 +263,7 @@ func (f *FIFO) GetByKey(key string) (item interface{}, exists bool, err error) { func (f *FIFO) IsClosed() bool { f.lock.Lock() defer f.lock.Unlock() - if f.closed { - return true - } - return false + return f.closed } // Pop waits until an item is ready and processes it. If multiple items are diff --git a/tools/cache/heap.go b/tools/cache/heap.go index e503a45a..819325e9 100644 --- a/tools/cache/heap.go +++ b/tools/cache/heap.go @@ -304,10 +304,7 @@ func (h *Heap) GetByKey(key string) (interface{}, bool, error) { func (h *Heap) IsClosed() bool { h.lock.RLock() defer h.lock.RUnlock() - if h.closed { - return true - } - return false + return h.closed } // NewHeap returns a Heap which can be used to queue up items to process. diff --git a/tools/clientcmd/config.go b/tools/clientcmd/config.go index 12c8b84f..31f89631 100644 --- a/tools/clientcmd/config.go +++ b/tools/clientcmd/config.go @@ -135,11 +135,7 @@ func (o *PathOptions) GetDefaultFilename() string { } func (o *PathOptions) IsExplicitFile() bool { - if len(o.LoadingRules.ExplicitPath) > 0 { - return true - } - - return false + return len(o.LoadingRules.ExplicitPath) > 0 } func (o *PathOptions) GetExplicitFile() string { diff --git a/tools/record/util/util.go b/tools/record/util/util.go index d1818a8d..afcc6a6a 100644 --- a/tools/record/util/util.go +++ b/tools/record/util/util.go @@ -36,9 +36,5 @@ func ValidateEventType(eventtype string) bool { func IsKeyNotFoundError(err error) bool { statusErr, _ := err.(*errors.StatusError) - if statusErr != nil && statusErr.Status().Code == http.StatusNotFound { - return true - } - - return false + return statusErr != nil && statusErr.Status().Code == http.StatusNotFound }