diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 57feb3d9e0..2c4abde79a 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -1354,7 +1354,7 @@ func TestAgent_unloadChecks(t *testing.T) { t.Fatalf("err: %s", err) } found := false - for check, _ := range agent.state.Checks() { + for check := range agent.state.Checks() { if check == check1.CheckID { found = true break @@ -1370,7 +1370,7 @@ func TestAgent_unloadChecks(t *testing.T) { } // Make sure it was unloaded - for check, _ := range agent.state.Checks() { + for check := range agent.state.Checks() { if check == check1.CheckID { t.Fatalf("should have unloaded checks") } @@ -1416,7 +1416,7 @@ func TestAgent_unloadServices(t *testing.T) { t.Fatalf("err: %v", err) } found := false - for id, _ := range agent.state.Services() { + for id := range agent.state.Services() { if id == svc.ID { found = true break @@ -1433,7 +1433,7 @@ func TestAgent_unloadServices(t *testing.T) { // Make sure it was unloaded and the consul service remains found = false - for id, _ := range agent.state.Services() { + for id := range agent.state.Services() { if id == svc.ID { t.Fatalf("should have unloaded services") } diff --git a/command/agent/coordinate_endpoint.go b/command/agent/coordinate_endpoint.go index 334bff9f44..0ad94fe8c9 100644 --- a/command/agent/coordinate_endpoint.go +++ b/command/agent/coordinate_endpoint.go @@ -51,7 +51,7 @@ func (s *HTTPServer) CoordinateDatacenters(resp http.ResponseWriter, req *http.R // Use empty list instead of nil (these aren't really possible because // Serf will give back a default coordinate and there's always one DC, // but it's better to be explicit about what we want here). - for i, _ := range out { + for i := range out { if out[i].Coordinates == nil { out[i].Coordinates = make(structs.Coordinates, 0) } diff --git a/command/agent/dns_test.go b/command/agent/dns_test.go index be5b980b14..ffaa5d2d0e 100644 --- a/command/agent/dns_test.go +++ b/command/agent/dns_test.go @@ -4175,7 +4175,7 @@ func TestDNS_trimUDPResponse_TrimSize(t *testing.T) { if len(resp.Answer) == 0 || len(resp.Answer) != len(resp.Extra) { t.Fatalf("Bad %#v", *resp) } - for i, _ := range resp.Answer { + for i := range resp.Answer { srv, ok := resp.Answer[i].(*dns.SRV) if !ok { t.Fatalf("should be SRV") diff --git a/command/agent/health_endpoint.go b/command/agent/health_endpoint.go index 700f368a51..ab7ee4d7f6 100644 --- a/command/agent/health_endpoint.go +++ b/command/agent/health_endpoint.go @@ -140,7 +140,7 @@ func (s *HTTPServer) HealthServiceNodes(resp http.ResponseWriter, req *http.Requ translateAddresses(s.agent.config, args.Datacenter, out.Nodes) // Use empty list instead of nil - for i, _ := range out.Nodes { + for i := range out.Nodes { // TODO (slackpad) It's lame that this isn't a slice of pointers // but it's not a well-scoped change to fix this. We should // change this at the next opportunity. diff --git a/command/agent/local.go b/command/agent/local.go index 2fc5d9f6b6..5af99d4235 100644 --- a/command/agent/local.go +++ b/command/agent/local.go @@ -446,7 +446,7 @@ func (l *localState) setSyncState() error { services = out1.NodeServices.Services } - for id, _ := range l.services { + for id := range l.services { // If the local service doesn't exist remotely, then sync it if _, ok := services[id]; !ok { l.serviceStatus[id] = syncStatus{inSync: false} @@ -479,7 +479,7 @@ func (l *localState) setSyncState() error { } // Sync any check which doesn't exist on the remote side - for id, _ := range l.checks { + for id := range l.checks { if _, ok := checkIndex[id]; !ok { l.checkStatus[id] = syncStatus{inSync: false} } diff --git a/command/agent/session_endpoint.go b/command/agent/session_endpoint.go index 8d07d3b9cd..b0d792b267 100644 --- a/command/agent/session_endpoint.go +++ b/command/agent/session_endpoint.go @@ -75,7 +75,7 @@ func FixupLockDelay(raw interface{}) error { return nil } var key string - for k, _ := range rawMap { + for k := range rawMap { if strings.ToLower(k) == "lockdelay" { key = k break diff --git a/consul/acl.go b/consul/acl.go index 316a010e48..a30a03a4b7 100644 --- a/consul/acl.go +++ b/consul/acl.go @@ -379,7 +379,7 @@ func (f *aclFilter) filterHealthChecks(checks *structs.HealthChecks) { // filterServices is used to filter a set of services based on ACLs. func (f *aclFilter) filterServices(services structs.Services) { - for svc, _ := range services { + for svc := range services { if f.allowService(svc) { continue } @@ -415,7 +415,7 @@ func (f *aclFilter) filterNodeServices(services **structs.NodeServices) { return } - for svc, _ := range (*services).Services { + for svc := range (*services).Services { if f.allowService(svc) { continue } diff --git a/consul/leader.go b/consul/leader.go index 68a2cd36db..a42d648130 100644 --- a/consul/leader.go +++ b/consul/leader.go @@ -439,7 +439,7 @@ func (s *Server) handleAliveMember(member serf.Member) error { return err } if services != nil { - for id, _ := range services.Services { + for id := range services.Services { if id == service.ID { match = true } diff --git a/consul/servers/manager.go b/consul/servers/manager.go index 99e3e7a19c..8955110ffa 100644 --- a/consul/servers/manager.go +++ b/consul/servers/manager.go @@ -421,7 +421,7 @@ func (m *Manager) RemoveServer(s *agent.Server) { l := m.getServerList() // Remove the server if known - for i, _ := range l.servers { + for i := range l.servers { if l.servers[i].Name == s.Name { newServers := make([]*agent.Server, 0, len(l.servers)-1) newServers = append(newServers, l.servers[:i]...) diff --git a/consul/servers/router.go b/consul/servers/router.go index 894474daca..80a0735d3a 100644 --- a/consul/servers/router.go +++ b/consul/servers/router.go @@ -316,7 +316,7 @@ func (r *Router) GetDatacenters() []string { defer r.RUnlock() dcs := make([]string, 0, len(r.managers)) - for dc, _ := range r.managers { + for dc := range r.managers { dcs = append(dcs, dc) } @@ -404,7 +404,7 @@ func (r *Router) GetDatacentersByDistance() ([]string, error) { // First sort by DC name, since we do a stable sort later. names := make([]string, 0, len(dcs)) - for dc, _ := range dcs { + for dc := range dcs { names = append(names, dc) } sort.Strings(names) diff --git a/consul/state/catalog.go b/consul/state/catalog.go index 9b1d1eca79..f25333429f 100644 --- a/consul/state/catalog.go +++ b/consul/state/catalog.go @@ -501,7 +501,7 @@ func (s *StateStore) Services(ws memdb.WatchSet) (uint64, structs.Services, erro var results = make(structs.Services) for service, tags := range unique { results[service] = make([]string, 0) - for tag, _ := range tags { + for tag := range tags { results[service] = append(results[service], tag) } } @@ -570,7 +570,7 @@ func (s *StateStore) ServicesByNodeMeta(ws memdb.WatchSet, filters map[string]st var results = make(structs.Services) for service, tags := range unique { results[service] = make([]string, 0) - for tag, _ := range tags { + for tag := range tags { results[service] = append(results[service], tag) } } diff --git a/consul/state/notify.go b/consul/state/notify.go index 3b991a656a..c215987e97 100644 --- a/consul/state/notify.go +++ b/consul/state/notify.go @@ -18,7 +18,7 @@ type NotifyGroup struct { func (n *NotifyGroup) Notify() { n.l.Lock() defer n.l.Unlock() - for ch, _ := range n.notify { + for ch := range n.notify { select { case ch <- struct{}{}: default: diff --git a/consul/state/session_test.go b/consul/state/session_test.go index caa6feb4b3..5a54b1bdc7 100644 --- a/consul/state/session_test.go +++ b/consul/state/session_test.go @@ -430,7 +430,7 @@ func TestStateStore_Session_Snapshot_Restore(t *testing.T) { dump = append(dump, sess) found := false - for i, _ := range sessions { + for i := range sessions { if sess.ID == sessions[i].ID { if !reflect.DeepEqual(sess, sessions[i]) { t.Fatalf("bad: %#v", sess) @@ -465,7 +465,7 @@ func TestStateStore_Session_Snapshot_Restore(t *testing.T) { } for _, sess := range res { found := false - for i, _ := range sessions { + for i := range sessions { if sess.ID == sessions[i].ID { if !reflect.DeepEqual(sess, sessions[i]) { t.Fatalf("bad: %#v", sess) diff --git a/consul/state/state_store.go b/consul/state/state_store.go index 06481db031..837a4f6f80 100644 --- a/consul/state/state_store.go +++ b/consul/state/state_store.go @@ -117,7 +117,7 @@ func (s *StateStore) Snapshot() *StateSnapshot { tx := s.db.Txn(false) var tables []string - for table, _ := range s.schema.Tables { + for table := range s.schema.Tables { tables = append(tables, table) } idx := maxIndexTxn(tx, tables...) diff --git a/consul/state/txn_test.go b/consul/state/txn_test.go index ee07f83c29..24254cea6f 100644 --- a/consul/state/txn_test.go +++ b/consul/state/txn_test.go @@ -289,7 +289,7 @@ func TestStateStore_Txn_KVS(t *testing.T) { if len(results) != len(expected) { t.Fatalf("bad: %v", results) } - for i, _ := range results { + for i := range results { if !reflect.DeepEqual(results[i], expected[i]) { t.Fatalf("bad %d", i) } @@ -334,7 +334,7 @@ func TestStateStore_Txn_KVS(t *testing.T) { if len(actual) != len(entries) { t.Fatalf("bad len: %d != %d", len(actual), len(entries)) } - for i, _ := range actual { + for i := range actual { if !reflect.DeepEqual(actual[i], entries[i]) { t.Fatalf("bad %d", i) } @@ -405,7 +405,7 @@ func TestStateStore_Txn_KVS_Rollback(t *testing.T) { if len(actual) != len(entries) { t.Fatalf("bad len (%s): %d != %d", desc, len(actual), len(entries)) } - for i, _ := range actual { + for i := range actual { if !reflect.DeepEqual(actual[i], entries[i]) { t.Fatalf("bad (%s): op %d: %v != %v", desc, i, *(actual[i]), *(entries[i])) } @@ -642,7 +642,7 @@ func TestStateStore_Txn_KVS_RO(t *testing.T) { if len(results) != len(expected) { t.Fatalf("bad: %v", results) } - for i, _ := range results { + for i := range results { if !reflect.DeepEqual(results[i], expected[i]) { t.Fatalf("bad %d", i) } diff --git a/logger/log_writer.go b/logger/log_writer.go index 02ce16bd1e..283acbfcf5 100644 --- a/logger/log_writer.go +++ b/logger/log_writer.go @@ -76,7 +76,7 @@ func (l *LogWriter) Write(p []byte) (n int, err error) { l.logs[l.index] = string(p) l.index = (l.index + 1) % len(l.logs) - for lh, _ := range l.handlers { + for lh := range l.handlers { lh.HandleLog(string(p)) } return diff --git a/snapshot/archive.go b/snapshot/archive.go index d4eccb43c6..b6db126a8a 100644 --- a/snapshot/archive.go +++ b/snapshot/archive.go @@ -84,7 +84,7 @@ func (hl *hashList) DecodeAndVerify(r io.Reader) error { } // Make sure everything we had a hash for was seen. - for file, _ := range hl.hashes { + for file := range hl.hashes { if _, ok := seen[file]; !ok { return fmt.Errorf("file missing for %q", file) } diff --git a/snapshot/snapshot_test.go b/snapshot/snapshot_test.go index 2a64343b41..45e0b3297e 100644 --- a/snapshot/snapshot_test.go +++ b/snapshot/snapshot_test.go @@ -205,7 +205,7 @@ func TestSnapshot(t *testing.T) { if len(fsm.logs) != len(expected) { t.Fatalf("bad: %d vs. %d", len(fsm.logs), len(expected)) } - for i, _ := range fsm.logs { + for i := range fsm.logs { if !bytes.Equal(fsm.logs[i], expected[i].Bytes()) { t.Fatalf("bad: log %d doesn't match", i) } @@ -300,7 +300,7 @@ func TestSnapshot_BadRestore(t *testing.T) { if len(fsm.logs) != len(expected) { t.Fatalf("bad: %d vs. %d", len(fsm.logs), len(expected)) } - for i, _ := range fsm.logs { + for i := range fsm.logs { if !bytes.Equal(fsm.logs[i], expected[i].Bytes()) { t.Fatalf("bad: log %d doesn't match", i) }