build: use Go 1.22 range over ints

Done with:

```
git grep -l 'for.*:= 0.*++' \
  | xargs sed -i -E 's/for (.*) := 0; \1 < (.*); \1\+\+/for \1 := range \2/'
```

And a few manual fixes due to unused variables. There is something fishy
in BMP rib test. Add a comment about that. This is not equivalent (as
with range, random is evaluated once, while in the original loop, it is
evaluated at each iteration). I believe the intent was to behave like
with range.
This commit is contained in:
Vincent Bernat
2024-08-14 08:48:33 +02:00
parent 88386b8ffe
commit a449736a62
26 changed files with 46 additions and 45 deletions

View File

@@ -78,7 +78,7 @@ func DefaultValuesUnmarshallerHook[Configuration any](defaultConfiguration Confi
// Which field is not to the default value in the default configuration?
found := map[string]bool{}
defaultV := reflect.ValueOf(defaultConfiguration)
for i := 0; i < defaultV.NumField(); i++ {
for i := range defaultV.NumField() {
if !defaultV.Field(i).IsZero() {
found[defaultV.Type().Field(i).Name] = false
}
@@ -148,7 +148,7 @@ func ParametrizedConfigurationUnmarshallerHook[OuterConfiguration any, InnerConf
return nil, errors.New("configuration should not have a `config' key")
default:
t := to.Type()
for i := 0; i < t.NumField(); i++ {
for i := range t.NumField() {
if MapStructureMatchName(keyStr, t.Field(i).Name) {
// Don't touch
continue outer