From 71d64f911f438ff968b5adfae3b328410e0b9096 Mon Sep 17 00:00:00 2001 From: Asim Date: Wed, 24 Aug 2016 18:37:11 +0100 Subject: [PATCH] make a copy of services for handle method --- registry/consul_watcher.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/registry/consul_watcher.go b/registry/consul_watcher.go index b143b05e..8571985d 100644 --- a/registry/consul_watcher.go +++ b/registry/consul_watcher.go @@ -201,7 +201,11 @@ func (cw *consulWatcher) handle(idx uint64, data interface{}) { } cw.RLock() - rservices := cw.services + // make a copy + rservices := make(map[string][]*Service) + for k, v := range cw.services { + rservices[k] = v + } cw.RUnlock() // remove unknown services from registry