use empty slice instead of nil slice when no tags exist for service

This commit is contained in:
Andrew M Bursavich 2014-05-13 00:18:36 -07:00 committed by Andrew M Bursavich
parent 686fac0e49
commit f48dcf0984
2 changed files with 6 additions and 1 deletions

View File

@ -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)

View File

@ -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 {