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

use Go 1.22 range over integers syntax #6214

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion internal/featuretests/v3/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ func TestRDSAssertNoDataRaceDuringInsertAndStream(t *testing.T) {
rh.OnAdd(s1)

go func() {
for i := 0; i < 100; i++ {
for i := range 100 {
rh.OnAdd(&contour_v1.HTTPProxy{
ObjectMeta: meta_v1.ObjectMeta{
Name: fmt.Sprintf("simple-%d", i),
Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func ValidateListeners(listeners []gatewayapi_v1.Listener) ValidateListenersResu
// This allows Listeners that appear first in list
// order to take precedence, i.e. to be accepted and
// programmed, when there is a conflict.
for j := 0; j < i; j++ {
for j := range i {
otherListener := listeners[j]

if listener.Port != otherListener.Port {
Expand Down
4 changes: 2 additions & 2 deletions internal/sorter/sorter.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func compareRoutesByMethodHeaderQueryParams(lhs, rhs *dag.Route) bool {

// HeaderMatchConditions are equal length: compare item by item.
pair := make([]dag.HeaderMatchCondition, 2)
for i := 0; i < len(lhsHeaderMatchConditions); i++ {
for i := range len(lhsHeaderMatchConditions) {
pair[0] = lhsHeaderMatchConditions[i]
pair[1] = rhsHeaderMatchConditions[i]

Expand All @@ -271,7 +271,7 @@ func compareRoutesByMethodHeaderQueryParams(lhs, rhs *dag.Route) bool {
}

// QueryParamMatchConditions are equal length: compare item by item.
for i := 0; i < len(lhs.QueryParamMatchConditions); i++ {
for i := range len(lhs.QueryParamMatchConditions) {
qPair := make([]dag.QueryParamMatchCondition, 2)
qPair[0] = lhs.QueryParamMatchConditions[i]
qPair[1] = rhs.QueryParamMatchConditions[i]
Expand Down
2 changes: 1 addition & 1 deletion internal/sorter/sorter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ func shuffleAndCheckSort[T any](t *testing.T, want []T) {
t.Helper()

// Run multiple trials so we catch any ordering/stability errors.
for i := 0; i < 10; i++ {
for range 10 {
have := shuffleSlice(want)

sort.Stable(For(have))
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/bench/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ var _ = Describe("Benchmark", func() {
client := &http.Client{
Timeout: time.Millisecond * 500,
}
for i := 0; i < numServices; i++ {
for i := range numServices {
appName := fmt.Sprintf("echo-%d", i)
deployApp(appName)
req, err := http.NewRequest(http.MethodGet, "http://"+lbExternalIP, nil)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ func (d *Deployment) EnvoyResourceAndName() string {
func randomString(n int) string {
const letters = "abcdefghijklmnopqrstuvwxyz0123456789"
ret := make([]byte, n)
for i := 0; i < n; i++ {
for i := range n {
num, err := rand.Int(rand.Reader, big.NewInt(int64(len(letters))))
if err != nil {
return ""
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/gateway/response_header_modifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func testResponseHeaderModifierBackendRef(namespace string, gateway types.Namesp

seenBackends := map[string]struct{}{}
// Retry a bunch of times to make sure we get to both backends.
for i := 0; i < 20; i++ {
for range 20 {
res, ok := f.HTTP.RequestUntil(&e2e.HTTPRequestOpts{
Host: string(route.Spec.Hostnames[0]),
Path: "/filter",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/httpproxy/cookie_rewrite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func testAppCookieRewrite(namespace string) {
// Rewrite on a service, balancing to multiple services.
services := map[string]struct{}{}
// Use a few attempts to make sure we hit both services.
for i := 0; i < 20; i++ {
for range 20 {
headers = requestSetCookieHeader(false, p.Spec.VirtualHost.Fqdn, "/service", "service=baz; Path=/svc")
for headerName, values := range headers {
if headerName != "Set-Cookie" {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/incluster/memory_usage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func testHeaderMatchIncludesMemoryUsage(namespace string) {
numHeaderMatches = 5
)

for i := 0; i < numChildren; i++ {
for i := range numChildren {
include := contour_v1.Include{
Name: fmt.Sprintf("child-%d", i),
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/incluster/smoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func testSimpleSmoke(namespace string) {
// This test may become flaky and should be investigated if there
// are changes that cause differences between the leader and
// non-leader contour instances.
for i := 0; i < 20; i++ {
for i := range 20 {
f.Fixtures.Echo.Deploy(namespace, fmt.Sprintf("echo-%d", i))

p := &contour_v1.HTTPProxy{
Expand Down
Loading