From 3a4c016df7b4760ff864c37a0023152066410578 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 20 Mar 2020 19:14:01 +0900 Subject: [PATCH] refactoring: variable naming --- command.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/command.go b/command.go index 55ddc50f..b70b93b7 100644 --- a/command.go +++ b/command.go @@ -1100,11 +1100,11 @@ func (c *Command) Commands() []*Command { // AddCommand adds one or more commands to this parent command. func (c *Command) AddCommand(cmds ...*Command) { - for i, x := range cmds { - if cmds[i] == c { + for _, x := range cmds { + if x == c { panic("Command can't be a child of itself") } - cmds[i].parent = c + x.parent = c // update max lengths usageLen := len(x.Use) if usageLen > c.commandsMaxUseLen {