From f48dcf0984c8ac6aff21c49f8dc314f57f1b28b8 Mon Sep 17 00:00:00 2001 From: Andrew M Bursavich Date: Tue, 13 May 2014 00:18:36 -0700 Subject: [PATCH] use empty slice instead of nil slice when no tags exist for service --- consul/catalog_endpoint_test.go | 5 +++++ consul/state_store.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/consul/catalog_endpoint_test.go b/consul/catalog_endpoint_test.go index 3a174ce456..a74a212771 100644 --- a/consul/catalog_endpoint_test.go +++ b/consul/catalog_endpoint_test.go @@ -449,6 +449,11 @@ func TestCatalogListServices(t *testing.T) { if len(out.Services) != 2 { t.Fatalf("bad: %v", out) } + for _, s := range out.Services { + if s == nil { + t.Fatalf("bad: %v", s) + } + } // Consul service should auto-register if _, ok := out.Services["consul"]; !ok { t.Fatalf("bad: %v", out) diff --git a/consul/state_store.go b/consul/state_store.go index 1de90c1b36..a5e99162ea 100644 --- a/consul/state_store.go +++ b/consul/state_store.go @@ -480,7 +480,7 @@ func (s *StateStore) Services() (uint64, map[string][]string) { srv := r.(*structs.ServiceNode) tags, ok := services[srv.ServiceName] if !ok { - services[srv.ServiceName] = tags + services[srv.ServiceName] = make([]string, 0) } for _, tag := range srv.ServiceTags {