From 9293f5b3cc6f5a96a1976bf2f810c957044c5ee8 Mon Sep 17 00:00:00 2001 From: Lynn Cyrin Date: Sun, 14 Jul 2019 21:00:16 -0700 Subject: [PATCH] visually shorten logic --- context.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/context.go b/context.go index 600307a..8caf90d 100644 --- a/context.go +++ b/context.go @@ -294,12 +294,10 @@ func checkRequiredFlags(flags []Flag, set *flag.FlagSet) error { }) for _, f := range flags { - if rf, ok := f.(RequiredFlag); ok { - if rf.IsRequired() { - key := strings.Split(f.GetName(), ",")[0] - if !visited[key] { - return fmt.Errorf("Required flag %q not set", f.GetName()) - } + if rf, ok := f.(RequiredFlag); ok && rf.IsRequired() { + key := strings.Split(f.GetName(), ",")[0] + if !visited[key] { + return fmt.Errorf("Required flag %q not set", f.GetName()) } } }