Skip to content

Commit

Permalink
use Go 1.22 range over integers syntax
Browse files Browse the repository at this point in the history
See https://go.dev/doc/go1.22#language.

Signed-off-by: Steve Kriss <stephen.kriss@gmail.com>
  • Loading branch information
skriss committed Feb 22, 2024
1 parent 9d7f9dd commit b56769b
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/projectcontour/contour

go 1.21
go 1.22

require (
dario.cat/mergo v1.0.0
Expand Down
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 {

Check failure on line 991 in internal/featuretests/v3/route_test.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over 100 (untyped int constant) (typecheck)
rh.OnAdd(&contour_v1.HTTPProxy{
ObjectMeta: meta_v1.ObjectMeta{
Name: fmt.Sprintf("simple-%d", i),
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) {

Check failure on line 264 in internal/sorter/sorter.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over len(lhsHeaderMatchConditions) (value of type int) (typecheck)
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) {

Check failure on line 274 in internal/sorter/sorter.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over len(lhs.QueryParamMatchConditions) (value of type int) (typecheck)
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 {

Check failure on line 723 in internal/sorter/sorter_test.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over 10 (untyped int constant) (typecheck)
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 {

Check failure on line 293 in test/e2e/bench/bench_test.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over numServices (variable of type int) (typecheck)
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 {

Check failure on line 988 in test/e2e/deployment.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over n (variable of type int) (typecheck)
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 {

Check failure on line 97 in test/e2e/gateway/response_header_modifier_test.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over 20 (untyped int constant) (typecheck)
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 {

Check failure on line 393 in test/e2e/httpproxy/cookie_rewrite_test.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over 20 (untyped int constant) (typecheck)
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 {

Check failure on line 56 in test/e2e/incluster/memory_usage_test.go

View workflow job for this annotation

GitHub Actions / lint

cannot range over numChildren (untyped int constant 100) (typecheck)
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

0 comments on commit b56769b

Please sign in to comment.