From f9709ffa6e3cdfa67f73b82a86d2d9545c79e17d Mon Sep 17 00:00:00 2001 From: Asim Date: Fri, 18 Nov 2016 07:30:50 +0000 Subject: [PATCH] ensure the code does not panic --- registry/consul_registry.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/registry/consul_registry.go b/registry/consul_registry.go index 32a12490..1f5d40b2 100644 --- a/registry/consul_registry.go +++ b/registry/consul_registry.go @@ -55,13 +55,12 @@ func newConsulRegistry(opts ...Option) Registry { config := consul.DefaultConfig() if options.Context != nil { // Use the consul config passed in the options, if available - c := options.Context.Value("consul_config") - if c != nil { - config = c.(*consul.Config) + if c, ok := options.Context.Value("consul_config").(*consul.Config); ok { + config = c } - t := options.Context.Value("consul_token") - if t != nil { - config.Token = t.(string) + + if t, ok := options.Context.Value("consul_token").(string); ok { + config.Token = t } }