Skip to content

Commit 1d951ec

Browse files
committed
Go 1.22.
1 parent c0298ad commit 1d951ec

File tree

20 files changed

+45
-50
lines changed

20 files changed

+45
-50
lines changed

driver/driver.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -720,19 +720,19 @@ func (r *rows) ColumnTypeScanType(index int) (typ reflect.Type) {
720720

721721
switch scan {
722722
case _INT:
723-
return reflect.TypeOf(int64(0))
723+
return reflect.TypeFor[int64]()
724724
case _REAL:
725-
return reflect.TypeOf(float64(0))
725+
return reflect.TypeFor[float64]()
726726
case _TEXT:
727-
return reflect.TypeOf("")
727+
return reflect.TypeFor[string]()
728728
case _BLOB:
729-
return reflect.TypeOf([]byte{})
729+
return reflect.TypeFor[[]byte]()
730730
case _BOOL:
731-
return reflect.TypeOf(false)
731+
return reflect.TypeFor[bool]()
732732
case _TIME:
733-
return reflect.TypeOf(time.Time{})
733+
return reflect.TypeFor[time.Time]()
734734
default:
735-
return reflect.TypeOf((*any)(nil)).Elem()
735+
return reflect.TypeFor[any]()
736736
}
737737
}
738738

driver/driver_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,13 @@ func Test_time(t *testing.T) {
369369

370370
func Test_ColumnType_ScanType(t *testing.T) {
371371
var (
372-
INT = reflect.TypeOf(int64(0))
373-
REAL = reflect.TypeOf(float64(0))
374-
TEXT = reflect.TypeOf("")
375-
BLOB = reflect.TypeOf([]byte{})
376-
BOOL = reflect.TypeOf(false)
377-
TIME = reflect.TypeOf(time.Time{})
378-
ANY = reflect.TypeOf((*any)(nil)).Elem()
372+
INT = reflect.TypeFor[int64]()
373+
REAL = reflect.TypeFor[float64]()
374+
TEXT = reflect.TypeFor[string]()
375+
BLOB = reflect.TypeFor[[]byte]()
376+
BOOL = reflect.TypeFor[bool]()
377+
TIME = reflect.TypeFor[time.Time]()
378+
ANY = reflect.TypeFor[any]()
379379
)
380380

381381
t.Parallel()

driver/util_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package driver
33
import (
44
"context"
55
"database/sql/driver"
6-
"reflect"
6+
"slices"
77
"testing"
88

99
_ "github.com/ncruces/go-sqlite3/embed"
@@ -16,7 +16,7 @@ func Test_namedValues(t *testing.T) {
1616
{Ordinal: 2, Value: false},
1717
}
1818
got := namedValues([]driver.Value{true, false})
19-
if !reflect.DeepEqual(got, want) {
19+
if !slices.Equal(got, want) {
2020
t.Errorf("got %v, want %v", got, want)
2121
}
2222
}

embed/bcw2/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/ncruces/go-sqlite3/embed/bcw2
22

3-
go 1.21
3+
go 1.22
44

55
toolchain go1.23.0
66

ext/blobio/blob_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"io"
55
"log"
66
"os"
7-
"reflect"
7+
"slices"
88
"strings"
99
"testing"
1010

@@ -278,7 +278,7 @@ func Test_openblob(t *testing.T) {
278278
}
279279

280280
want := []string{"\xca\xfe", "\xba\xbe"}
281-
if !reflect.DeepEqual(got, want) {
281+
if !slices.Equal(got, want) {
282282
t.Errorf("got %v, want %v", got, want)
283283
}
284284
}

ext/bloom/bloom.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func (b *bloom) Update(arg ...sqlite3.Value) (rowid int64, err error) {
232232
}
233233
defer f.Close()
234234

235-
for n := 0; n < b.hashes; n++ {
235+
for n := range b.hashes {
236236
hash := calcHash(n, blob)
237237
hash %= uint64(b.bytes * 8)
238238
bitpos := byte(hash % 8)

ext/closure/closure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func (c *cursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value) error {
210210
c.nodes = []node{{root, 0}}
211211
set := util.Set[int64]{}
212212
set.Add(root)
213-
for i := 0; i < len(c.nodes); i++ {
213+
for i := range c.nodes {
214214
curr := c.nodes[i]
215215
if curr.depth >= maxDepth {
216216
continue

ext/pivot/pivot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func (c *cursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value) error {
207207
func (c *cursor) Next() error {
208208
if c.scan.Step() {
209209
count := c.scan.ColumnCount()
210-
for i := 0; i < count; i++ {
210+
for i := range count {
211211
err := c.cell.BindValue(i+1, c.scan.ColumnValue(i))
212212
if err != nil {
213213
return err

ext/statement/stmt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func declare(db *sqlite3.Conn, _, _, _ string, arg ...string) (*table, error) {
4444
var str strings.Builder
4545
str.WriteString("CREATE TABLE x(")
4646
outputs := stmt.ColumnCount()
47-
for i := 0; i < outputs; i++ {
47+
for i := range outputs {
4848
name := sqlite3.QuoteIdentifier(stmt.ColumnName(i))
4949
str.WriteString(sep)
5050
str.WriteString(name)

ext/unicode/unicode_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package unicode
22

33
import (
44
"errors"
5-
"reflect"
5+
"slices"
66
"testing"
77

88
"github.com/ncruces/go-sqlite3"
@@ -121,7 +121,7 @@ func TestRegister_collation(t *testing.T) {
121121
t.Fatal(err)
122122
}
123123

124-
if !reflect.DeepEqual(got, want) {
124+
if !slices.Equal(got, want) {
125125
t.Error("not equal")
126126
}
127127

@@ -172,7 +172,7 @@ func TestRegisterCollationsNeeded(t *testing.T) {
172172
t.Fatal(err)
173173
}
174174

175-
if !reflect.DeepEqual(got, want) {
175+
if !slices.Equal(got, want) {
176176
t.Error("not equal")
177177
}
178178

0 commit comments

Comments
 (0)