mirror of https://github.com/status-im/consul.git
golint: Drop the unused value from range
for i, _ := range foo -> for i := range foo
This commit is contained in:
parent
2fc6541fd3
commit
8bb7792799
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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]...)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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...)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue