From c5318e892e6545332fa505a660043b2938c3a551 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 15 Jul 2016 10:42:19 -0700 Subject: [PATCH] type check to avoid panic License: MIT Signed-off-by: Jeromy --- core/commands/config.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/commands/config.go b/core/commands/config.go index 502abe37e..586c579a6 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -162,7 +162,13 @@ included in the output of this command. return } - delete(cfg["Identity"].(map[string]interface{}), "PrivKey") + idmap, ok := cfg["Identity"].(map[string]interface{}) + if !ok { + res.SetError(fmt.Errorf("config has no identity"), cmds.ErrNormal) + return + } + + delete(idmap, "PrivKey") output, err := config.HumanOutput(cfg) if err != nil {