Skip to content

Commit 7914c6b

Browse files
kyleconroyclaude
andauthored
Upgrade to Go 1.26 and apply go fix (#10)
* Upgrade to Go 1.26 and apply go fix Bump go directive in both modules to 1.26 and apply the modernization fixes that go fix produces under the new toolchain (range-over-int, strings.SplitSeq, strings.Cut, interface{} -> any). * Fix go vet warnings and run vet in CI - Pass a constant format string to yylex.Errorf in parser.y so go vet's printf check is satisfied; regenerate parser/parser.go. - Discard the unused fmt.Sprintf result in BenchmarkDigestSprintf. - Bump CI Go version to 1.26 and add a go vet step. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 244112b commit 7914c6b

11 files changed

Lines changed: 25 additions & 22 deletions

File tree

.github/workflows/go.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up Go
1515
uses: actions/setup-go@v5
1616
with:
17-
go-version: '1.25'
17+
go-version: '1.26'
1818

1919
- name: Regenerate parser
2020
run: |
@@ -31,5 +31,8 @@ jobs:
3131
- name: Build
3232
run: go build ./...
3333

34+
- name: Vet
35+
run: go vet ./...
36+
3437
- name: Test
3538
run: go test ./...

ast/base_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func buildNoQuotesClause() string {
294294
func buildMixedQuery(n int) string {
295295
var b strings.Builder
296296
b.WriteString("SELECT * FROM t1 WHERE ")
297-
for i := 0; i < n; i++ {
297+
for i := range n {
298298
if i > 0 {
299299
b.WriteString(" OR ")
300300
}
@@ -310,7 +310,7 @@ func buildMixedQuery(n int) string {
310310
func buildQuery(clause string, n int) string {
311311
var b strings.Builder
312312
b.WriteString("SELECT * FROM t1 WHERE ")
313-
for i := 0; i < n; i++ {
313+
for i := range n {
314314
if i > 0 {
315315
b.WriteString(" OR ")
316316
}

ast/misc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3993,7 +3993,7 @@ type HintTimeRange struct {
39933993
// will be parsed into a LeadingList like:
39943994
// Items = [HintTable("a"), LeadingList{[HintTable("b"), HintTable("c")]}, HintTable("d")]
39953995
type LeadingList struct {
3996-
Items []interface{}
3996+
Items []any
39973997
}
39983998

39993999
// HintSetVar is the payload of `SET_VAR` hint

generate_keyword/genkeyword.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func main() {
110110
}
111111

112112
section := sectionNone
113-
for _, line := range strings.Split(string(parserData), "\n") {
113+
for line := range strings.SplitSeq(string(parserData), "\n") {
114114
if line == "" { // Empty line indicates section end
115115
section = sectionNone
116116
} else if strings.Contains(line, reservedKeywordStart) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/sqlc-dev/marino
22

3-
go 1.25
3+
go 1.26
44

55
require golang.org/x/text v0.19.0

goyacc/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/sqlc-dev/marino/goyacc
22

3-
go 1.25
3+
go 1.26
44

55
require (
66
github.com/sqlc-dev/marino v0.0.0

parser/consistent_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ func extractMiddle(str, startMarker, endMarker string) string {
8181
return ""
8282
}
8383
str = str[startIdx+len(startMarker):]
84-
endIdx := strings.Index(str, endMarker)
85-
if endIdx == -1 {
84+
before, _, ok := strings.Cut(str, endMarker)
85+
if !ok {
8686
return ""
8787
}
88-
return str[:endIdx]
88+
return before
8989
}
9090

9191
func extractQuotedWords(strs []string) []string {

parser/digester_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,6 @@ func BenchmarkDigestSprintf(b *testing.B) {
296296
digest1 := genRandDigest("abc")
297297
b.ResetTimer()
298298
for i := 0; i < b.N; i++ {
299-
fmt.Sprintf("%x", digest1)
299+
_ = fmt.Sprintf("%x", digest1)
300300
}
301301
}

parser/hintparser_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,13 @@ func TestParseHint(t *testing.T) {
374374
{
375375
HintName: ast.NewCIStr("LEADING"),
376376
HintData: &ast.LeadingList{
377-
Items: []interface{}{
377+
Items: []any{
378378
&ast.HintTable{TableName: ast.NewCIStr("a")},
379379
&ast.LeadingList{
380-
Items: []interface{}{
380+
Items: []any{
381381
&ast.HintTable{TableName: ast.NewCIStr("b")},
382382
&ast.LeadingList{
383-
Items: []interface{}{
383+
Items: []any{
384384
&ast.HintTable{TableName: ast.NewCIStr("c")},
385385
&ast.HintTable{TableName: ast.NewCIStr("d")},
386386
},
@@ -404,7 +404,7 @@ func TestParseHint(t *testing.T) {
404404
{
405405
HintName: ast.NewCIStr("LEADING"),
406406
HintData: &ast.LeadingList{
407-
Items: []interface{}{
407+
Items: []any{
408408
&ast.HintTable{TableName: ast.NewCIStr("a")},
409409
&ast.HintTable{TableName: ast.NewCIStr("b")},
410410
&ast.HintTable{TableName: ast.NewCIStr("c")},
@@ -424,15 +424,15 @@ func TestParseHint(t *testing.T) {
424424
{
425425
HintName: ast.NewCIStr("LEADING"),
426426
HintData: &ast.LeadingList{
427-
Items: []interface{}{
427+
Items: []any{
428428
&ast.LeadingList{
429-
Items: []interface{}{
429+
Items: []any{
430430
&ast.HintTable{TableName: ast.NewCIStr("a")},
431431
&ast.HintTable{TableName: ast.NewCIStr("b")},
432432
},
433433
},
434434
&ast.LeadingList{
435-
Items: []interface{}{
435+
Items: []any{
436436
&ast.HintTable{TableName: ast.NewCIStr("c")},
437437
&ast.HintTable{TableName: ast.NewCIStr("d")},
438438
},
@@ -454,10 +454,10 @@ func TestParseHint(t *testing.T) {
454454
{
455455
HintName: ast.NewCIStr("LEADING"),
456456
HintData: &ast.LeadingList{
457-
Items: []interface{}{
457+
Items: []any{
458458
&ast.HintTable{TableName: ast.NewCIStr("x")},
459459
&ast.LeadingList{
460-
Items: []interface{}{
460+
Items: []any{
461461
&ast.HintTable{TableName: ast.NewCIStr("y")},
462462
&ast.HintTable{TableName: ast.NewCIStr("z")},
463463
},

parser/parser.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)