Skip to content

Commit 11a7bdc

Browse files
authored
chore: migrate to go1.26 (#5332)
1 parent bd18fbc commit 11a7bdc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+184
-199
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
3636
with:
3737
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
38-
version: latest
38+
version: v2.9.0
3939
args: --timeout 10m
4040

4141
spelling:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.25-alpine3.21 AS builder
1+
FROM golang:1.26-alpine3.23 AS builder
22

33
ENV BUILD_IN_DOCKER=true
44
ARG VERSION

core/human/marshal.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,7 @@ func computeMaxCols(grid [][]string) int {
461461
func getDefaultFieldsOpt(t reflect.Type) []*MarshalFieldOpt {
462462
results := []*MarshalFieldOpt(nil)
463463
// Loop through all struct field
464-
for fieldIdx := range t.NumField() {
465-
field := t.Field(fieldIdx)
464+
for field := range t.Fields() {
466465
fieldType := field.Type
467466

468467
if field.Anonymous {

core/reflect.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@ import (
1515
// becomes struct{FieldName string `json:"field_name"`}
1616
func newObjectWithForcedJSONTags(t reflect.Type) any {
1717
structFieldsCopy := []reflect.StructField(nil)
18-
for i := range t.NumField() {
19-
fieldCopy := t.Field(i)
18+
for fieldCopy := range t.Fields() {
2019
if fieldCopy.Anonymous {
2120
anonymousType := fieldCopy.Type
2221
if anonymousType.Kind() == reflect.Ptr {
2322
anonymousType = anonymousType.Elem()
2423
}
25-
for i := range anonymousType.NumField() {
26-
fieldCopy := anonymousType.Field(i)
27-
fieldCopy.Tag = reflect.StructTag(
24+
for field := range anonymousType.Fields() {
25+
field.Tag = reflect.StructTag(
2826
`json:"` + strings.ReplaceAll(
29-
strcase.ToBashArg(fieldCopy.Name),
27+
strcase.ToBashArg(field.Name),
3028
"-",
3129
"_",
3230
) + `"`,
3331
)
34-
structFieldsCopy = append(structFieldsCopy, fieldCopy)
32+
structFieldsCopy = append(structFieldsCopy, field)
3533
}
3634
} else {
3735
fieldCopy.Tag = reflect.StructTag(

core/testing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ func Test(config *TestConfig) func(t *testing.T) {
343343
}
344344

345345
// We need to set up this variable to ensure that relative date parsing stay consistent
346-
args.TestForceNow = scw.TimePtr(time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC))
346+
args.TestForceNow = new(time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC))
347347

348348
// Because human marshal of date is relative (e.g 3 minutes ago) we must make sure it stay consistent for golden to works.
349349
// Here we return a constant string. We may need to find a better place to put this.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/scaleway/scaleway-cli/v2
22

3-
go 1.25.5
3+
go 1.26.0
44

55
require (
66
github.com/aws/aws-sdk-go-v2 v1.41.1

internal/args/args.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ func listArgTypeFields(base string, argType reflect.Type) []string {
297297
case reflect.Struct:
298298
fields := []string(nil)
299299

300-
for i := range argType.NumField() {
301-
field := argType.Field(i)
300+
for field := range argType.Fields() {
302301
fieldBase := base
303302

304303
// If this is an embedded struct, skip adding its name to base

internal/args/unmarshal_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
func init() {
16-
args.TestForceNow = scw.TimePtr(time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC))
16+
args.TestForceNow = new(time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC))
1717
}
1818

1919
func TestUnmarshalStruct(t *testing.T) {
@@ -205,7 +205,7 @@ func TestUnmarshalStruct(t *testing.T) {
205205
},
206206
expected: &Slice{
207207
Strings: []string(nil),
208-
SlicePtr: scw.StringsPtr([]string{}),
208+
SlicePtr: new([]string{}),
209209
StringsPtr: []*string(nil),
210210
},
211211
}))

internal/editor/reflect_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func Test_valueMapperPointersWithPointers(t *testing.T) {
7878
src := struct {
7979
Arg1 *string
8080
Arg2 *int32
81-
}{scw.StringPtr("1"), scw.Int32Ptr(1)}
81+
}{new("1"), scw.Int32Ptr(1)}
8282
dest := struct {
8383
Arg1 *string
8484
Arg2 *int32

internal/gofields/gofields.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,7 @@ func listFields(t reflect.Type, parents []string, filter ListFieldFilter) []stri
178178
return listFields(t.Elem(), append(parents, "<key>"), filter)
179179
case reflect.Struct:
180180
res := []string(nil)
181-
for i := range t.NumField() {
182-
field := t.Field(i)
183-
181+
for field := range t.Fields() {
184182
if !isFieldPublic(field) {
185183
continue
186184
}

0 commit comments

Comments
 (0)