golint: Drop the unused value from range

for i, _ := range foo -> for i := range foo
This commit is contained in:
Frank Schroeder 2017-04-20 11:42:22 -07:00 committed by Frank Schröder
parent b264d5cfe3
commit ebdb73d8f2
18 changed files with 30 additions and 30 deletions

View File

@ -1354,7 +1354,7 @@ func TestAgent_unloadChecks(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
found := false found := false
for check, _ := range agent.state.Checks() { for check := range agent.state.Checks() {
if check == check1.CheckID { if check == check1.CheckID {
found = true found = true
break break
@ -1370,7 +1370,7 @@ func TestAgent_unloadChecks(t *testing.T) {
} }
// Make sure it was unloaded // Make sure it was unloaded
for check, _ := range agent.state.Checks() { for check := range agent.state.Checks() {
if check == check1.CheckID { if check == check1.CheckID {
t.Fatalf("should have unloaded checks") t.Fatalf("should have unloaded checks")
} }
@ -1416,7 +1416,7 @@ func TestAgent_unloadServices(t *testing.T) {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }
found := false found := false
for id, _ := range agent.state.Services() { for id := range agent.state.Services() {
if id == svc.ID { if id == svc.ID {
found = true found = true
break break
@ -1433,7 +1433,7 @@ func TestAgent_unloadServices(t *testing.T) {
// Make sure it was unloaded and the consul service remains // Make sure it was unloaded and the consul service remains
found = false found = false
for id, _ := range agent.state.Services() { for id := range agent.state.Services() {
if id == svc.ID { if id == svc.ID {
t.Fatalf("should have unloaded services") t.Fatalf("should have unloaded services")
} }

View File

@ -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 // 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, // 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). // 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 { if out[i].Coordinates == nil {
out[i].Coordinates = make(structs.Coordinates, 0) out[i].Coordinates = make(structs.Coordinates, 0)
} }

View File

@ -4175,7 +4175,7 @@ func TestDNS_trimUDPResponse_TrimSize(t *testing.T) {
if len(resp.Answer) == 0 || len(resp.Answer) != len(resp.Extra) { if len(resp.Answer) == 0 || len(resp.Answer) != len(resp.Extra) {
t.Fatalf("Bad %#v", *resp) t.Fatalf("Bad %#v", *resp)
} }
for i, _ := range resp.Answer { for i := range resp.Answer {
srv, ok := resp.Answer[i].(*dns.SRV) srv, ok := resp.Answer[i].(*dns.SRV)
if !ok { if !ok {
t.Fatalf("should be SRV") t.Fatalf("should be SRV")

View File

@ -140,7 +140,7 @@ func (s *HTTPServer) HealthServiceNodes(resp http.ResponseWriter, req *http.Requ
translateAddresses(s.agent.config, args.Datacenter, out.Nodes) translateAddresses(s.agent.config, args.Datacenter, out.Nodes)
// Use empty list instead of nil // 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 // 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 // but it's not a well-scoped change to fix this. We should
// change this at the next opportunity. // change this at the next opportunity.

View File

@ -446,7 +446,7 @@ func (l *localState) setSyncState() error {
services = out1.NodeServices.Services 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 the local service doesn't exist remotely, then sync it
if _, ok := services[id]; !ok { if _, ok := services[id]; !ok {
l.serviceStatus[id] = syncStatus{inSync: false} 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 // 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 { if _, ok := checkIndex[id]; !ok {
l.checkStatus[id] = syncStatus{inSync: false} l.checkStatus[id] = syncStatus{inSync: false}
} }

View File

@ -75,7 +75,7 @@ func FixupLockDelay(raw interface{}) error {
return nil return nil
} }
var key string var key string
for k, _ := range rawMap { for k := range rawMap {
if strings.ToLower(k) == "lockdelay" { if strings.ToLower(k) == "lockdelay" {
key = k key = k
break break

View File

@ -379,7 +379,7 @@ func (f *aclFilter) filterHealthChecks(checks *structs.HealthChecks) {
// filterServices is used to filter a set of services based on ACLs. // filterServices is used to filter a set of services based on ACLs.
func (f *aclFilter) filterServices(services structs.Services) { func (f *aclFilter) filterServices(services structs.Services) {
for svc, _ := range services { for svc := range services {
if f.allowService(svc) { if f.allowService(svc) {
continue continue
} }
@ -415,7 +415,7 @@ func (f *aclFilter) filterNodeServices(services **structs.NodeServices) {
return return
} }
for svc, _ := range (*services).Services { for svc := range (*services).Services {
if f.allowService(svc) { if f.allowService(svc) {
continue continue
} }

View File

@ -439,7 +439,7 @@ func (s *Server) handleAliveMember(member serf.Member) error {
return err return err
} }
if services != nil { if services != nil {
for id, _ := range services.Services { for id := range services.Services {
if id == service.ID { if id == service.ID {
match = true match = true
} }

View File

@ -421,7 +421,7 @@ func (m *Manager) RemoveServer(s *agent.Server) {
l := m.getServerList() l := m.getServerList()
// Remove the server if known // Remove the server if known
for i, _ := range l.servers { for i := range l.servers {
if l.servers[i].Name == s.Name { if l.servers[i].Name == s.Name {
newServers := make([]*agent.Server, 0, len(l.servers)-1) newServers := make([]*agent.Server, 0, len(l.servers)-1)
newServers = append(newServers, l.servers[:i]...) newServers = append(newServers, l.servers[:i]...)

View File

@ -316,7 +316,7 @@ func (r *Router) GetDatacenters() []string {
defer r.RUnlock() defer r.RUnlock()
dcs := make([]string, 0, len(r.managers)) dcs := make([]string, 0, len(r.managers))
for dc, _ := range r.managers { for dc := range r.managers {
dcs = append(dcs, dc) 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. // First sort by DC name, since we do a stable sort later.
names := make([]string, 0, len(dcs)) names := make([]string, 0, len(dcs))
for dc, _ := range dcs { for dc := range dcs {
names = append(names, dc) names = append(names, dc)
} }
sort.Strings(names) sort.Strings(names)

View File

@ -501,7 +501,7 @@ func (s *StateStore) Services(ws memdb.WatchSet) (uint64, structs.Services, erro
var results = make(structs.Services) var results = make(structs.Services)
for service, tags := range unique { for service, tags := range unique {
results[service] = make([]string, 0) results[service] = make([]string, 0)
for tag, _ := range tags { for tag := range tags {
results[service] = append(results[service], tag) 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) var results = make(structs.Services)
for service, tags := range unique { for service, tags := range unique {
results[service] = make([]string, 0) results[service] = make([]string, 0)
for tag, _ := range tags { for tag := range tags {
results[service] = append(results[service], tag) results[service] = append(results[service], tag)
} }
} }

View File

@ -18,7 +18,7 @@ type NotifyGroup struct {
func (n *NotifyGroup) Notify() { func (n *NotifyGroup) Notify() {
n.l.Lock() n.l.Lock()
defer n.l.Unlock() defer n.l.Unlock()
for ch, _ := range n.notify { for ch := range n.notify {
select { select {
case ch <- struct{}{}: case ch <- struct{}{}:
default: default:

View File

@ -430,7 +430,7 @@ func TestStateStore_Session_Snapshot_Restore(t *testing.T) {
dump = append(dump, sess) dump = append(dump, sess)
found := false found := false
for i, _ := range sessions { for i := range sessions {
if sess.ID == sessions[i].ID { if sess.ID == sessions[i].ID {
if !reflect.DeepEqual(sess, sessions[i]) { if !reflect.DeepEqual(sess, sessions[i]) {
t.Fatalf("bad: %#v", sess) t.Fatalf("bad: %#v", sess)
@ -465,7 +465,7 @@ func TestStateStore_Session_Snapshot_Restore(t *testing.T) {
} }
for _, sess := range res { for _, sess := range res {
found := false found := false
for i, _ := range sessions { for i := range sessions {
if sess.ID == sessions[i].ID { if sess.ID == sessions[i].ID {
if !reflect.DeepEqual(sess, sessions[i]) { if !reflect.DeepEqual(sess, sessions[i]) {
t.Fatalf("bad: %#v", sess) t.Fatalf("bad: %#v", sess)

View File

@ -117,7 +117,7 @@ func (s *StateStore) Snapshot() *StateSnapshot {
tx := s.db.Txn(false) tx := s.db.Txn(false)
var tables []string var tables []string
for table, _ := range s.schema.Tables { for table := range s.schema.Tables {
tables = append(tables, table) tables = append(tables, table)
} }
idx := maxIndexTxn(tx, tables...) idx := maxIndexTxn(tx, tables...)

View File

@ -289,7 +289,7 @@ func TestStateStore_Txn_KVS(t *testing.T) {
if len(results) != len(expected) { if len(results) != len(expected) {
t.Fatalf("bad: %v", results) t.Fatalf("bad: %v", results)
} }
for i, _ := range results { for i := range results {
if !reflect.DeepEqual(results[i], expected[i]) { if !reflect.DeepEqual(results[i], expected[i]) {
t.Fatalf("bad %d", i) t.Fatalf("bad %d", i)
} }
@ -334,7 +334,7 @@ func TestStateStore_Txn_KVS(t *testing.T) {
if len(actual) != len(entries) { if len(actual) != len(entries) {
t.Fatalf("bad len: %d != %d", 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]) { if !reflect.DeepEqual(actual[i], entries[i]) {
t.Fatalf("bad %d", i) t.Fatalf("bad %d", i)
} }
@ -405,7 +405,7 @@ func TestStateStore_Txn_KVS_Rollback(t *testing.T) {
if len(actual) != len(entries) { if len(actual) != len(entries) {
t.Fatalf("bad len (%s): %d != %d", desc, 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]) { if !reflect.DeepEqual(actual[i], entries[i]) {
t.Fatalf("bad (%s): op %d: %v != %v", desc, i, *(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) { if len(results) != len(expected) {
t.Fatalf("bad: %v", results) t.Fatalf("bad: %v", results)
} }
for i, _ := range results { for i := range results {
if !reflect.DeepEqual(results[i], expected[i]) { if !reflect.DeepEqual(results[i], expected[i]) {
t.Fatalf("bad %d", i) t.Fatalf("bad %d", i)
} }

View File

@ -76,7 +76,7 @@ func (l *LogWriter) Write(p []byte) (n int, err error) {
l.logs[l.index] = string(p) l.logs[l.index] = string(p)
l.index = (l.index + 1) % len(l.logs) l.index = (l.index + 1) % len(l.logs)
for lh, _ := range l.handlers { for lh := range l.handlers {
lh.HandleLog(string(p)) lh.HandleLog(string(p))
} }
return return

View File

@ -84,7 +84,7 @@ func (hl *hashList) DecodeAndVerify(r io.Reader) error {
} }
// Make sure everything we had a hash for was seen. // 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 { if _, ok := seen[file]; !ok {
return fmt.Errorf("file missing for %q", file) return fmt.Errorf("file missing for %q", file)
} }

View File

@ -205,7 +205,7 @@ func TestSnapshot(t *testing.T) {
if len(fsm.logs) != len(expected) { if len(fsm.logs) != len(expected) {
t.Fatalf("bad: %d vs. %d", 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()) { if !bytes.Equal(fsm.logs[i], expected[i].Bytes()) {
t.Fatalf("bad: log %d doesn't match", i) 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) { if len(fsm.logs) != len(expected) {
t.Fatalf("bad: %d vs. %d", 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()) { if !bytes.Equal(fsm.logs[i], expected[i].Bytes()) {
t.Fatalf("bad: log %d doesn't match", i) t.Fatalf("bad: log %d doesn't match", i)
} }