Skip to content

Commit 858ecda

Browse files
authored
fix: insert entry during iterating over a map (#3398)
Signed-off-by: fukua95 <[email protected]>
1 parent 75e8370 commit 858ecda

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

command.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3584,15 +3584,14 @@ func (c *cmdsInfoCache) Get(ctx context.Context) (map[string]*CommandInfo, error
35843584
return err
35853585
}
35863586

3587+
lowerCmds := make(map[string]*CommandInfo, len(cmds))
3588+
35873589
// Extensions have cmd names in upper case. Convert them to lower case.
35883590
for k, v := range cmds {
3589-
lower := internal.ToLower(k)
3590-
if lower != k {
3591-
cmds[lower] = v
3592-
}
3591+
lowerCmds[internal.ToLower(k)] = v
35933592
}
35943593

3595-
c.cmds = cmds
3594+
c.cmds = lowerCmds
35963595
return nil
35973596
})
35983597
return c.cmds, err

0 commit comments

Comments
 (0)