Skip to content

Commit

Permalink
Handle different-length results more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
leizor committed May 6, 2024
1 parent a0574d7 commit f2f9ae9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions cmd/foobar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,21 @@ func checkHistogram(client remote.ReadClient, histogramBase string, hourStart ti
}
}

if len(res[0]) != len(res[1]) {
return -1, fmt.Errorf("result sets different lengths, %v != %v", len(res[0]), len(res[1]))
}
if len(res[0]) >= len(res[1]) {
for ts, v0 := range res[0] {
v1 := res[1][ts]
if v0 != v1 {
return ts, nil
}
}

for ts, v0 := range res[0] {
v1 := res[1][ts]
if v0 != v1 {
return ts, nil
return 0, nil
} else {
for ts, v0 := range res[1] {
v1 := res[0][ts]
if v0 != v1 {
return ts, nil
}
}
}

return 0, nil
}

Check failure on line 190 in cmd/foobar/main.go

View workflow job for this annotation

GitHub Actions / golangci-lint

missing return (typecheck)

Check failure on line 190 in cmd/foobar/main.go

View workflow job for this annotation

GitHub Actions / Go tests on Windows

missing return

0 comments on commit f2f9ae9

Please sign in to comment.