-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: fix govet-shadow lint #16608
*: fix govet-shadow lint #16608
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,33 +181,33 @@ func (t *Trace) logInfo(threshold time.Duration) (string, []zap.Field) { | |
var steps []string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is no longer needed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, Line 207 is still using it~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True
Think this function needs a for major redo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use tstep here based on t.steps. I mark it as TODO if need. |
||
lastStepTime := t.startTime | ||
for i := 0; i < len(t.steps); i++ { | ||
step := t.steps[i] | ||
tstep := t.steps[i] | ||
// add subtrace common fields which defined at the beginning to each sub-steps | ||
if step.isSubTraceStart { | ||
if tstep.isSubTraceStart { | ||
for j := i + 1; j < len(t.steps) && !t.steps[j].isSubTraceEnd; j++ { | ||
t.steps[j].fields = append(step.fields, t.steps[j].fields...) | ||
t.steps[j].fields = append(tstep.fields, t.steps[j].fields...) | ||
} | ||
continue | ||
} | ||
// add subtrace common fields which defined at the end to each sub-steps | ||
if step.isSubTraceEnd { | ||
if tstep.isSubTraceEnd { | ||
for j := i - 1; j >= 0 && !t.steps[j].isSubTraceStart; j-- { | ||
t.steps[j].fields = append(step.fields, t.steps[j].fields...) | ||
t.steps[j].fields = append(tstep.fields, t.steps[j].fields...) | ||
} | ||
continue | ||
} | ||
} | ||
for i := 0; i < len(t.steps); i++ { | ||
step := t.steps[i] | ||
if step.isSubTraceStart || step.isSubTraceEnd { | ||
tstep := t.steps[i] | ||
if tstep.isSubTraceStart || tstep.isSubTraceEnd { | ||
continue | ||
} | ||
stepDuration := step.time.Sub(lastStepTime) | ||
stepDuration := tstep.time.Sub(lastStepTime) | ||
if stepDuration > threshold { | ||
steps = append(steps, fmt.Sprintf("trace[%d] '%v' %s (duration: %v)", | ||
traceNum, step.msg, writeFields(step.fields), stepDuration)) | ||
traceNum, tstep.msg, writeFields(tstep.fields), stepDuration)) | ||
} | ||
lastStepTime = step.time | ||
lastStepTime = tstep.time | ||
} | ||
|
||
fs := []zap.Field{zap.String("detail", writeFields(t.fields)), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -477,8 +477,10 @@ func (s *EtcdServer) getPeerHashKVs(rev int64) []*peerHashKVResp { | |
respsLen := len(resps) | ||
var lastErr error | ||
for _, ep := range p.eps { | ||
var resp *pb.HashKVResponse | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), s.Cfg.ReqTimeout()) | ||
resp, lastErr := HashByRev(ctx, s.cluster.ID(), cc, ep, rev) | ||
resp, lastErr = HashByRev(ctx, s.cluster.ID(), cc, ep, rev) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create new var to prevent shadow the etcdserver/corrupt.go:481:10: declaration of "lastErr" shadows declaration at line 478 |
||
cancel() | ||
if lastErr == nil { | ||
resps = append(resps, &peerHashKVResp{peerInfo: p, resp: resp, err: nil}) | ||
|
@@ -535,7 +537,7 @@ func (h *hashKVHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
} | ||
|
||
req := &pb.HashKVRequest{} | ||
if err := json.Unmarshal(b, req); err != nil { | ||
if err = json.Unmarshal(b, req); err != nil { | ||
h.lg.Warn("failed to unmarshal request", zap.Error(err)) | ||
http.Error(w, "error unmarshalling request", http.StatusBadRequest) | ||
return | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,9 @@ func NewTmpWAL(t testing.TB, reqs []etcdserverpb.InternalRaftRequest) (*wal.WAL, | |
if err != nil { | ||
t.Fatalf("Failed to open WAL: %v", err) | ||
} | ||
_, state, _, err := w.ReadAll() | ||
|
||
var state raftpb.HardState | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creating new var |
||
_, state, _, err = w.ReadAll() | ||
if err != nil { | ||
t.Fatalf("Failed to read WAL: %v", err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use new
sresp
here because the old name shadows the L240../maintenance.go:253:4: declaration of "resp" shadows declaration at line 240