From 2633356842484b83fcdce4450e40767ee5be8309 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 27 Sep 2022 11:18:29 +0530 Subject: [PATCH] No need to use a map --- tools/cmd/at/main.go | 6 +++++- tools/cmd/at/template.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/cmd/at/main.go b/tools/cmd/at/main.go index 2d9a526b3..7d2f5b39f 100644 --- a/tools/cmd/at/main.go +++ b/tools/cmd/at/main.go @@ -285,7 +285,11 @@ func get_password(password string, password_file string, password_env string, us return ans, nil } -var all_commands map[string]func(*cli.Command) *cli.Command = make(map[string]func(*cli.Command) *cli.Command) +var all_commands []func(*cli.Command) *cli.Command = make([]func(*cli.Command) *cli.Command, 0, 64) + +func register_at_cmd(f func(*cli.Command) *cli.Command) { + all_commands = append(all_commands, f) +} func setup_global_options(cmd *cli.Command) (err error) { err = cmd.GetOptionValues(&rc_global_opts) diff --git a/tools/cmd/at/template.go b/tools/cmd/at/template.go index d5dd5398f..2327c1304 100644 --- a/tools/cmd/at/template.go +++ b/tools/cmd/at/template.go @@ -106,5 +106,5 @@ func setup_CMD_NAME(parent *cli.Command) *cli.Command { } func init() { - all_commands["CMD_NAME"] = setup_CMD_NAME + register_at_cmd(setup_CMD_NAME) }