From 62597fe929c72e20c3661d06b206a007526effb0 Mon Sep 17 00:00:00 2001 From: Dmitry Kutakov Date: Thu, 26 Dec 2019 14:05:50 +0100 Subject: [PATCH] simplify code - eliminate type assertions "gosimple" linter says: S1034: assigning the result of this type assertion to a variable (switch f := f.(type)) could eliminate the following type assertions: flag.go:267:26 flag.go:270:28 flag.go:273:30 flag.go:276:29 --- flag.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/flag.go b/flag.go index ec128fd..077a6dd 100644 --- a/flag.go +++ b/flag.go @@ -261,19 +261,19 @@ func flagValue(f Flag) reflect.Value { func stringifyFlag(f Flag) string { fv := flagValue(f) - switch f.(type) { + switch f := f.(type) { case *IntSliceFlag: return withEnvHint(flagStringSliceField(f, "EnvVars"), - stringifyIntSliceFlag(f.(*IntSliceFlag))) + stringifyIntSliceFlag(f)) case *Int64SliceFlag: return withEnvHint(flagStringSliceField(f, "EnvVars"), - stringifyInt64SliceFlag(f.(*Int64SliceFlag))) + stringifyInt64SliceFlag(f)) case *Float64SliceFlag: return withEnvHint(flagStringSliceField(f, "EnvVars"), - stringifyFloat64SliceFlag(f.(*Float64SliceFlag))) + stringifyFloat64SliceFlag(f)) case *StringSliceFlag: return withEnvHint(flagStringSliceField(f, "EnvVars"), - stringifyStringSliceFlag(f.(*StringSliceFlag))) + stringifyStringSliceFlag(f)) } placeholder, usage := unquoteUsage(fv.FieldByName("Usage").String())