type check to avoid panic
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
Jeromy committed
Jul 15, 2016 at 10:42 UTC
c5318e892e6545332fa505a660043b2938c3a551
1 file changed
+7
-1
core/commands/config.go
+7
-1
@@ -162,7 +162,13 @@ included in the output of this command.
162
return
163
}
164
165
- delete(cfg["Identity"].(map[string]interface{}), "PrivKey")
165
+ idmap, ok := cfg["Identity"].(map[string]interface{})
166
+ if !ok {
167
+ res.SetError(fmt.Errorf("config has no identity"), cmds.ErrNormal)
168
+ return
169
+ }
170
+
171
+ delete(idmap, "PrivKey")
172
173
output, err := config.HumanOutput(cfg)
174
if err != nil {