Skip to content
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 loopvar behavior change linting error #546

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions internal/dqrs/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ func (dqrs DNSQueryResponses) PrintSummary(outputFormat string, omitTimestamp bo
fmt.Fprintln(w, separatorRowTmpl)

for _, item := range dqrs {
// Building with `go build -gcflags=all=-d=loopvar=2` identified this
// loop as compiling differently with Go 1.22 (per-iteration) loop
// semantics. In particular, it is believed that the use of the Answer
// ([]dns.RR) struct field which caused this loop to be flagged.
//
// As a workaround, we create a new variable for each iteration to
// work around potential issues with Go versions prior to Go 1.22.
item := item

requestType, err := RRTypeToString(item.RequestedRecordType)
if err != nil {
Expand Down
Loading