Skip to content

Commit 0c676dc

Browse files
authored
Bump Go to 1.26.3 (#5302)
Bumps `go` to `1.26.0` and `toolchain` to `go1.26.3` across all four modules (root, `tools/`, `tools/task/`, `bundle/internal/tf/codegen/`), and folds in the `golangci-lint --fix` output that the new minor version requires. Bumping the `go` directive to 1.26 unlocks two `modernize` analyzers (already enabled in `.golangci.yaml`) that were silent on 1.25: - `stditerators` — prefer `reflect.Type.Fields()`/`Methods()` and `reflect.Value.Fields()`/`Methods()` over the `NumField()`/`Field(i)` loop pattern. - `newexpr` — replace local `*T` helpers like `func intPtr(v int) *int { return &v }` (and their callers) with Go 1.26's `new(expr)`. These fixes are in the same PR so CI doesn't fail the moment the bump lands. A manual fixup commit removes the redundant `field := field` shadows and the now-dead `*Ptr` helpers the auto-fix left behind (including rewriting 20 `int64Ptr(N)` callers to `new(int64(N))`). Release notes: https://go.dev/doc/go1.26 ## Test plan - `go build ./...` and `go vet ./...` clean on all four modules - `go tool -modfile=tools/go.mod golangci-lint run ./...` — 0 issues - Unit tests pass on all packages touched by the `--fix` and cleanup This pull request and its description were written by Isaac.
1 parent 946dc01 commit 0c676dc

20 files changed

Lines changed: 73 additions & 115 deletions

File tree

NEXT_CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88

99
### Bundles
1010
* The error reported when a direct-only resource (catalogs, external locations, vector search endpoints) is used with the terraform engine now also suggests setting `bundle.engine: direct` in `databricks.yml`, in addition to the `DATABRICKS_BUNDLE_ENGINE` environment variable ([#5295](https://github.com/databricks/cli/pull/5295)).
11+
12+
### Dependency updates
13+
* Bump Go toolchain to 1.26.3 ([#5302](https://github.com/databricks/cli/pull/5302)).

bundle/config/resources/dashboard_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ func TestDashboardConfigIsSupersetOfSDKDashboard(t *testing.T) {
2929

3030
// Create a map of SDK fields by name and their JSON tags
3131
sdkFields := make(map[string]string)
32-
for i := range sdkType.NumField() {
33-
field := sdkType.Field(i)
32+
for field := range sdkType.Fields() {
3433
jsonTag := field.Tag.Get("json")
3534
jsonName := getJSONTagName(jsonTag)
3635
if jsonName != "" {
@@ -40,8 +39,7 @@ func TestDashboardConfigIsSupersetOfSDKDashboard(t *testing.T) {
4039

4140
// Create a map of config fields by name and their JSON tags
4241
configFields := make(map[string]string)
43-
for i := range configType.NumField() {
44-
field := configType.Field(i)
42+
for field := range configType.Fields() {
4543
jsonTag := field.Tag.Get("json")
4644
jsonName := getJSONTagName(jsonTag)
4745
if jsonName != "" {

bundle/config/resources_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ import (
5353
func TestCustomMarshallerIsImplemented(t *testing.T) {
5454
rt := reflect.TypeFor[Resources]()
5555

56-
for i := range rt.NumField() {
57-
field := rt.Field(i)
58-
56+
for field := range rt.Fields() {
5957
// Fields in Resources are expected be of the form map[string]*resourceStruct
6058
assert.Equal(t, reflect.Map, field.Type.Kind(), "Resource %s is not a map", field.Name)
6159
kt := field.Type.Key()
@@ -95,8 +93,7 @@ func TestResourcesAllResourcesCompleteness(t *testing.T) {
9593
types = append(types, group.Description.PluralName)
9694
}
9795

98-
for i := range rt.NumField() {
99-
field := rt.Field(i)
96+
for field := range rt.Fields() {
10097
jsonTag := field.Tag.Get("json")
10198

10299
if idx := strings.Index(jsonTag, ","); idx != -1 {
@@ -112,8 +109,7 @@ func TestSupportedResources(t *testing.T) {
112109
actual := SupportedResources()
113110

114111
typ := reflect.TypeFor[Resources]()
115-
for i := range typ.NumField() {
116-
field := typ.Field(i)
112+
for field := range typ.Fields() {
117113
jsonTags := strings.Split(field.Tag.Get("json"), ",")
118114
pluralName := jsonTags[0]
119115
assert.Equal(t, actual[pluralName].PluralName, pluralName)

bundle/deploy/terraform/tfdyn/convert_job_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,7 @@ func TestSupportedTypeTasksComplete(t *testing.T) {
296296
taskType := reflect.TypeFor[jobs.Task]()
297297
var tasksWithSource []string
298298

299-
for i := range taskType.NumField() {
300-
field := taskType.Field(i)
301-
299+
for field := range taskType.Fields() {
302300
// Skip non-task fields (like DependsOn, Libraries, etc.)
303301
if !strings.HasSuffix(field.Name, "Task") {
304302
continue
@@ -351,9 +349,7 @@ func findSourceFieldsShallow(t reflect.Type) []string {
351349

352350
var paths []string
353351

354-
for i := range t.NumField() {
355-
field := t.Field(i)
356-
352+
for field := range t.Fields() {
357353
// Check if this field is named "Source"
358354
if field.Name == "Source" {
359355
paths = append(paths, "")

bundle/direct/dresources/app_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ func TestAppDoUpdate_UpdateMaskHasAllFields(t *testing.T) {
149149

150150
fields := reflect.TypeFor[apps.App]()
151151
var allFields []string
152-
for i := range fields.NumField() {
153-
field := fields.Field(i)
152+
for field := range fields.Fields() {
154153
jsonTag := field.Tag.Get("json")
155154
if jsonTag == "" || jsonTag == "-" {
156155
continue

bundle/direct/dresources/util_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ import (
1212
func assertFieldsCovered(t *testing.T, sdkType, remoteType reflect.Type, skip map[string]bool) {
1313
t.Helper()
1414
remoteFields := map[string]bool{}
15-
for i := range remoteType.NumField() {
16-
f := remoteType.Field(i)
15+
for f := range remoteType.Fields() {
1716
if !f.Anonymous {
1817
remoteFields[f.Name] = true
1918
}
2019
}
2120

22-
for i := range sdkType.NumField() {
23-
field := sdkType.Field(i)
21+
for field := range sdkType.Fields() {
2422
if skip[field.Name] {
2523
assert.NotContains(t, remoteFields, field.Name, "field %s is in skip list but present in %s; remove it from skip", field.Name, remoteType.Name())
2624
continue

bundle/docsgen/nodes_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestBuildNodes_ChildExpansion(t *testing.T) {
2525
Items: &jsonschema.Schema{
2626
Type: "object",
2727
Properties: map[string]*jsonschema.Schema{
28-
"listSub": {Reference: strPtr("#/$defs/github.com/listSub")},
28+
"listSub": {Reference: new("#/$defs/github.com/listSub")},
2929
},
3030
},
3131
},
@@ -61,9 +61,9 @@ func TestBuildNodes_ChildExpansion(t *testing.T) {
6161
"myMap": {
6262
Type: "object",
6363
AdditionalProperties: &jsonschema.Schema{
64-
Reference: strPtr("#/$defs/github.com/myMap"),
64+
Reference: new("#/$defs/github.com/myMap"),
6565
Properties: map[string]*jsonschema.Schema{
66-
"mapSub": {Type: "object", Reference: strPtr("#/$defs/github.com/mapSub")},
66+
"mapSub": {Type: "object", Reference: new("#/$defs/github.com/mapSub")},
6767
},
6868
},
6969
},
@@ -73,7 +73,7 @@ func TestBuildNodes_ChildExpansion(t *testing.T) {
7373
"github.com/myMap": {
7474
Type: "object",
7575
Properties: map[string]*jsonschema.Schema{
76-
"mapSub": {Type: "boolean", Reference: strPtr("#/$defs/github.com/mapSub")},
76+
"mapSub": {Type: "boolean", Reference: new("#/$defs/github.com/mapSub")},
7777
},
7878
},
7979
"github.com/mapSub": {
@@ -170,7 +170,3 @@ func TestDoNotSuggestFields(t *testing.T) {
170170
assert.Len(t, nodes[0].Attributes, 1)
171171
assert.Equal(t, "nestedNotDoNotSuggestField", nodes[0].Attributes[0].Title)
172172
}
173-
174-
func strPtr(s string) *string {
175-
return &s
176-
}

bundle/internal/schema/parser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ func (p *openapiParser) findRef(typ reflect.Type) (jsonschema.Schema, bool) {
5858

5959
// Check for embedded Databricks Go SDK types.
6060
if typ.Kind() == reflect.Struct {
61-
for i := range typ.NumField() {
62-
if !typ.Field(i).Anonymous {
61+
for field := range typ.Fields() {
62+
if !field.Anonymous {
6363
continue
6464
}
6565

6666
// Deference current type if it's a pointer.
67-
ctyp := typ.Field(i).Type
67+
ctyp := field.Type
6868
for ctyp.Kind() == reflect.Ptr {
6969
ctyp = ctyp.Elem()
7070
}

bundle/internal/tf/codegen/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module github.com/databricks/cli/bundle/internal/tf/codegen
22

3-
go 1.25.8
3+
go 1.26.0
44

5-
toolchain go1.25.10
5+
toolchain go1.26.3
66

77
require (
88
github.com/hashicorp/go-version v1.9.0

cmd/pipelines/history_test.go

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ func TestUpdatesBefore(t *testing.T) {
2424
}{
2525
{
2626
name: "before 700",
27-
timestamp: int64Ptr(700),
27+
timestamp: new(int64(700)),
2828
expectedCount: 3,
2929
expectedFirst: 600,
3030
},
3131
{
3232
name: "before 1000",
33-
timestamp: int64Ptr(1000),
33+
timestamp: new(int64(1000)),
3434
expectedCount: 5,
3535
expectedFirst: 1000,
3636
},
3737
{
3838
name: "before 200",
39-
timestamp: int64Ptr(200),
39+
timestamp: new(int64(200)),
4040
expectedCount: 1,
4141
expectedFirst: 200,
4242
},
4343
{
4444
name: "before 100",
45-
timestamp: int64Ptr(100),
45+
timestamp: new(int64(100)),
4646
expectedCount: 0,
4747
expectedFirst: 0,
4848
},
@@ -79,25 +79,25 @@ func TestUpdatesAfter(t *testing.T) {
7979
}{
8080
{
8181
name: "after 500",
82-
timestamp: int64Ptr(500),
82+
timestamp: new(int64(500)),
8383
expectedCount: 3,
8484
expectedFirst: 1000,
8585
},
8686
{
8787
name: "after 200",
88-
timestamp: int64Ptr(200),
88+
timestamp: new(int64(200)),
8989
expectedCount: 5,
9090
expectedFirst: 1000,
9191
},
9292
{
9393
name: "after 1000",
94-
timestamp: int64Ptr(1000),
94+
timestamp: new(int64(1000)),
9595
expectedCount: 1,
9696
expectedFirst: 1000,
9797
},
9898
{
9999
name: "after 1200",
100-
timestamp: int64Ptr(1200),
100+
timestamp: new(int64(1200)),
101101
expectedCount: 0,
102102
expectedFirst: 0,
103103
},
@@ -181,15 +181,15 @@ func TestFilterUpdates(t *testing.T) {
181181
name: "start time nil, end time set",
182182
updates: updates,
183183
startTime: nil,
184-
endTime: int64Ptr(700),
184+
endTime: new(int64(700)),
185185
expectedCount: 3,
186186
expectedFirst: 600,
187187
expectedLast: 200,
188188
},
189189
{
190190
name: "start time set, end time nil",
191191
updates: updates,
192-
startTime: int64Ptr(500),
192+
startTime: new(int64(500)),
193193
endTime: nil,
194194
expectedCount: 3,
195195
expectedFirst: 1000,
@@ -198,25 +198,25 @@ func TestFilterUpdates(t *testing.T) {
198198
{
199199
name: "both times set within range",
200200
updates: updates,
201-
startTime: int64Ptr(300),
202-
endTime: int64Ptr(900),
201+
startTime: new(int64(300)),
202+
endTime: new(int64(900)),
203203
expectedCount: 3,
204204
expectedFirst: 800,
205205
expectedLast: 400,
206206
},
207207
{
208208
name: "both times set, no overlap",
209209
updates: updates,
210-
startTime: int64Ptr(1200),
211-
endTime: int64Ptr(1500),
210+
startTime: new(int64(1200)),
211+
endTime: new(int64(1500)),
212212
expectedCount: 0,
213213
expectedFirst: 0,
214214
expectedLast: 0,
215215
},
216216
{
217217
name: "start time after all updates",
218218
updates: updates,
219-
startTime: int64Ptr(1200),
219+
startTime: new(int64(1200)),
220220
endTime: nil,
221221
expectedCount: 0,
222222
expectedFirst: 0,
@@ -226,25 +226,25 @@ func TestFilterUpdates(t *testing.T) {
226226
name: "end time before all updates",
227227
updates: updates,
228228
startTime: nil,
229-
endTime: int64Ptr(100),
229+
endTime: new(int64(100)),
230230
expectedCount: 0,
231231
expectedFirst: 0,
232232
expectedLast: 0,
233233
},
234234
{
235235
name: "start time after end time but within range",
236236
updates: updates,
237-
startTime: int64Ptr(700),
238-
endTime: int64Ptr(500),
237+
startTime: new(int64(700)),
238+
endTime: new(int64(500)),
239239
expectedCount: 0,
240240
expectedFirst: 0,
241241
expectedLast: 0,
242242
},
243243
{
244244
name: "start and end time match exact values in list",
245245
updates: updates,
246-
startTime: int64Ptr(400),
247-
endTime: int64Ptr(800),
246+
startTime: new(int64(400)),
247+
endTime: new(int64(800)),
248248
expectedCount: 3,
249249
expectedFirst: 800,
250250
expectedLast: 400,
@@ -289,6 +289,3 @@ func TestFilterUpdates(t *testing.T) {
289289
})
290290
}
291291
}
292-
293-
// Helper function to create int64 pointers
294-
func int64Ptr(v int64) *int64 { return &v }

0 commit comments

Comments
 (0)