move empty tag check inside the loop

This commit is contained in:
Alex Flint 2020-07-06 09:54:23 -07:00
parent 2a3b5ea3cb
commit 6be0398e80
1 changed files with 62 additions and 61 deletions

View File

@ -292,8 +292,10 @@ func cmdFromStruct(name string, dest path, t reflect.Type) (*command, error) {
// Look at the tag // Look at the tag
var isSubcommand bool // tracks whether this field is a subcommand var isSubcommand bool // tracks whether this field is a subcommand
if tag != "" {
for _, key := range strings.Split(tag, ",") { for _, key := range strings.Split(tag, ",") {
if key == "" {
continue
}
key = strings.TrimLeft(key, " ") key = strings.TrimLeft(key, " ")
var value string var value string
if pos := strings.Index(key, ":"); pos != -1 { if pos := strings.Index(key, ":"); pos != -1 {
@ -357,7 +359,6 @@ func cmdFromStruct(name string, dest path, t reflect.Type) (*command, error) {
return false return false
} }
} }
}
placeholder, hasPlaceholder := field.Tag.Lookup("placeholder") placeholder, hasPlaceholder := field.Tag.Lookup("placeholder")
if hasPlaceholder { if hasPlaceholder {