Skip to content

Commit c91bca4

Browse files
committedJan 25, 2024
update go version to 1.19
1 parent 00b02e0 commit c91bca4

21 files changed

+88
-89
lines changed
 

‎.github/workflows/go.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest, macos-latest]
17-
go: ['1.18', '1.19', '1.20']
17+
go: ['1.19', '1.20', '1.21']
1818
fail-fast: false
1919
env:
2020
OS: ${{ matrix.os }}
@@ -64,7 +64,7 @@ jobs:
6464

6565
strategy:
6666
matrix:
67-
go: ['1.18', '1.19', '1.20']
67+
go: ['1.19', '1.20', '1.21']
6868
fail-fast: false
6969
env:
7070
OS: windows-latest

‎_example/limit/limit.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"github.com/mattn/go-sqlite3"
1111
)
1212

13-
func createBulkInsertQuery(n int, start int) (query string, args []interface{}) {
13+
func createBulkInsertQuery(n int, start int) (query string, args []any) {
1414
values := make([]string, n)
15-
args = make([]interface{}, n*2)
15+
args = make([]any, n*2)
1616
pos := 0
1717
for i := 0; i < n; i++ {
1818
values[i] = "(?, ?)"
@@ -27,7 +27,7 @@ func createBulkInsertQuery(n int, start int) (query string, args []interface{})
2727
return
2828
}
2929

30-
func bulkInsert(db *sql.DB, query string, args []interface{}) (err error) {
30+
func bulkInsert(db *sql.DB, query string, args []any) (err error) {
3131
stmt, err := db.Prepare(query)
3232
if err != nil {
3333
return

‎_example/vtable/vtable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (vc *ghRepoCursor) Column(c *sqlite3.SQLiteContext, col int) error {
9393
return nil
9494
}
9595

96-
func (vc *ghRepoCursor) Filter(idxNum int, idxStr string, vals []interface{}) error {
96+
func (vc *ghRepoCursor) Filter(idxNum int, idxStr string, vals []any) error {
9797
vc.index = 0
9898
return nil
9999
}

‎_example/vtable_eponymous_only/vtable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (vc *seriesCursor) Column(c *sqlite3.SQLiteContext, col int) error {
7777
return nil
7878
}
7979

80-
func (vc *seriesCursor) Filter(idxNum int, idxStr string, vals []interface{}) error {
80+
func (vc *seriesCursor) Filter(idxNum int, idxStr string, vals []any) error {
8181
switch {
8282
case len(vals) < 1:
8383
vc.seriesTable.start = 0

‎callback.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ func preUpdateHookTrampoline(handle unsafe.Pointer, dbHandle uintptr, op int, db
100100
// Use handles to avoid passing Go pointers to C.
101101
type handleVal struct {
102102
db *SQLiteConn
103-
val interface{}
103+
val any
104104
}
105105

106106
var handleLock sync.Mutex
107107
var handleVals = make(map[unsafe.Pointer]handleVal)
108108

109-
func newHandle(db *SQLiteConn, v interface{}) unsafe.Pointer {
109+
func newHandle(db *SQLiteConn, v any) unsafe.Pointer {
110110
handleLock.Lock()
111111
defer handleLock.Unlock()
112112
val := handleVal{db: db, val: v}
@@ -124,7 +124,7 @@ func lookupHandleVal(handle unsafe.Pointer) handleVal {
124124
return handleVals[handle]
125125
}
126126

127-
func lookupHandle(handle unsafe.Pointer) interface{} {
127+
func lookupHandle(handle unsafe.Pointer) any {
128128
return lookupHandleVal(handle).val
129129
}
130130

@@ -238,7 +238,7 @@ func callbackArg(typ reflect.Type) (callbackArgConverter, error) {
238238
switch typ.Kind() {
239239
case reflect.Interface:
240240
if typ.NumMethod() != 0 {
241-
return nil, errors.New("the only supported interface type is interface{}")
241+
return nil, errors.New("the only supported interface type is any")
242242
}
243243
return callbackArgGeneric, nil
244244
case reflect.Slice:

‎callback_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestCallbackArgCast(t *testing.T) {
5353

5454
func TestCallbackConverters(t *testing.T) {
5555
tests := []struct {
56-
v interface{}
56+
v any
5757
err bool
5858
}{
5959
// Unfortunately, we can't tell which converter was returned,
@@ -104,7 +104,7 @@ func TestCallbackConverters(t *testing.T) {
104104
}
105105

106106
func TestCallbackReturnAny(t *testing.T) {
107-
udf := func() interface{} {
107+
udf := func() any {
108108
return 1
109109
}
110110

‎convert.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var errNilPtr = errors.New("destination pointer is nil") // embedded in descript
2323
// convertAssign copies to dest the value in src, converting it if possible.
2424
// An error is returned if the copy would result in loss of information.
2525
// dest should be a pointer type.
26-
func convertAssign(dest, src interface{}) error {
26+
func convertAssign(dest, src any) error {
2727
// Common cases, without reflect.
2828
switch s := src.(type) {
2929
case string:
@@ -55,7 +55,7 @@ func convertAssign(dest, src interface{}) error {
5555
}
5656
*d = string(s)
5757
return nil
58-
case *interface{}:
58+
case *any:
5959
if d == nil {
6060
return errNilPtr
6161
}
@@ -97,7 +97,7 @@ func convertAssign(dest, src interface{}) error {
9797
}
9898
case nil:
9999
switch d := dest.(type) {
100-
case *interface{}:
100+
case *any:
101101
if d == nil {
102102
return errNilPtr
103103
}
@@ -149,7 +149,7 @@ func convertAssign(dest, src interface{}) error {
149149
*d = bv.(bool)
150150
}
151151
return err
152-
case *interface{}:
152+
case *any:
153153
*d = src
154154
return nil
155155
}
@@ -256,7 +256,7 @@ func cloneBytes(b []byte) []byte {
256256
return c
257257
}
258258

259-
func asString(src interface{}) string {
259+
func asString(src any) string {
260260
switch v := src.(type) {
261261
case string:
262262
return v

‎doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ You can also use database/sql.Conn.Raw (Go >= 1.13):
9595
conn, err := db.Conn(context.Background())
9696
// if err != nil { ... }
9797
defer conn.Close()
98-
err = conn.Raw(func (driverConn interface{}) error {
98+
err = conn.Raw(func (driverConn any) error {
9999
sqliteConn := driverConn.(*sqlite3.SQLiteConn)
100100
// ... use sqliteConn
101101
})

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/mattn/go-sqlite3
22

3-
go 1.16
3+
go 1.19
44

55
retract (
66
[v2.0.0+incompatible, v2.0.6+incompatible] // Accidental; no major changes or features.

‎sqlite3.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,9 @@ func (c *SQLiteConn) RegisterAuthorizer(callback func(int, string, string, strin
607607
// RegisterFunc makes a Go function available as a SQLite function.
608608
//
609609
// The Go function can have arguments of the following types: any
610-
// numeric type except complex, bool, []byte, string and
611-
// interface{}. interface{} arguments are given the direct translation
612-
// of the SQLite data type: int64 for INTEGER, float64 for FLOAT,
613-
// []byte for BLOB, string for TEXT.
610+
// numeric type except complex, bool, []byte, string and any.
611+
// any arguments are given the direct translation of the SQLite data type:
612+
// int64 for INTEGER, float64 for FLOAT, []byte for BLOB, string for TEXT.
614613
//
615614
// The function can additionally be variadic, as long as the type of
616615
// the variadic argument is one of the above.
@@ -620,7 +619,7 @@ func (c *SQLiteConn) RegisterAuthorizer(callback func(int, string, string, strin
620619
// optimizations in its queries.
621620
//
622621
// See _example/go_custom_funcs for a detailed example.
623-
func (c *SQLiteConn) RegisterFunc(name string, impl interface{}, pure bool) error {
622+
func (c *SQLiteConn) RegisterFunc(name string, impl any, pure bool) error {
624623
var fi functionInfo
625624
fi.f = reflect.ValueOf(impl)
626625
t := fi.f.Type()
@@ -702,7 +701,7 @@ func sqlite3CreateFunction(db *C.sqlite3, zFunctionName *C.char, nArg C.int, eTe
702701
// return an error in addition to their other return values.
703702
//
704703
// See _example/go_custom_funcs for a detailed example.
705-
func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool) error {
704+
func (c *SQLiteConn) RegisterAggregator(name string, impl any, pure bool) error {
706705
var ai aggInfo
707706
ai.constructor = reflect.ValueOf(impl)
708707
t := ai.constructor.Type()

‎sqlite3_func_crypt.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ import (
5050
// perhaps using a cryptographic hash function like SHA1.
5151

5252
// CryptEncoderSHA1 encodes a password with SHA1
53-
func CryptEncoderSHA1(pass []byte, hash interface{}) []byte {
53+
func CryptEncoderSHA1(pass []byte, hash any) []byte {
5454
h := sha1.Sum(pass)
5555
return h[:]
5656
}
5757

5858
// CryptEncoderSSHA1 encodes a password with SHA1 with the
5959
// configured salt.
60-
func CryptEncoderSSHA1(salt string) func(pass []byte, hash interface{}) []byte {
61-
return func(pass []byte, hash interface{}) []byte {
60+
func CryptEncoderSSHA1(salt string) func(pass []byte, hash any) []byte {
61+
return func(pass []byte, hash any) []byte {
6262
s := []byte(salt)
6363
p := append(pass, s...)
6464
h := sha1.Sum(p)
@@ -67,15 +67,15 @@ func CryptEncoderSSHA1(salt string) func(pass []byte, hash interface{}) []byte {
6767
}
6868

6969
// CryptEncoderSHA256 encodes a password with SHA256
70-
func CryptEncoderSHA256(pass []byte, hash interface{}) []byte {
70+
func CryptEncoderSHA256(pass []byte, hash any) []byte {
7171
h := sha256.Sum256(pass)
7272
return h[:]
7373
}
7474

7575
// CryptEncoderSSHA256 encodes a password with SHA256
7676
// with the configured salt
77-
func CryptEncoderSSHA256(salt string) func(pass []byte, hash interface{}) []byte {
78-
return func(pass []byte, hash interface{}) []byte {
77+
func CryptEncoderSSHA256(salt string) func(pass []byte, hash any) []byte {
78+
return func(pass []byte, hash any) []byte {
7979
s := []byte(salt)
8080
p := append(pass, s...)
8181
h := sha256.Sum256(p)
@@ -84,15 +84,15 @@ func CryptEncoderSSHA256(salt string) func(pass []byte, hash interface{}) []byte
8484
}
8585

8686
// CryptEncoderSHA384 encodes a password with SHA384
87-
func CryptEncoderSHA384(pass []byte, hash interface{}) []byte {
87+
func CryptEncoderSHA384(pass []byte, hash any) []byte {
8888
h := sha512.Sum384(pass)
8989
return h[:]
9090
}
9191

9292
// CryptEncoderSSHA384 encodes a password with SHA384
9393
// with the configured salt
94-
func CryptEncoderSSHA384(salt string) func(pass []byte, hash interface{}) []byte {
95-
return func(pass []byte, hash interface{}) []byte {
94+
func CryptEncoderSSHA384(salt string) func(pass []byte, hash any) []byte {
95+
return func(pass []byte, hash any) []byte {
9696
s := []byte(salt)
9797
p := append(pass, s...)
9898
h := sha512.Sum384(p)
@@ -101,15 +101,15 @@ func CryptEncoderSSHA384(salt string) func(pass []byte, hash interface{}) []byte
101101
}
102102

103103
// CryptEncoderSHA512 encodes a password with SHA512
104-
func CryptEncoderSHA512(pass []byte, hash interface{}) []byte {
104+
func CryptEncoderSHA512(pass []byte, hash any) []byte {
105105
h := sha512.Sum512(pass)
106106
return h[:]
107107
}
108108

109109
// CryptEncoderSSHA512 encodes a password with SHA512
110110
// with the configured salt
111-
func CryptEncoderSSHA512(salt string) func(pass []byte, hash interface{}) []byte {
112-
return func(pass []byte, hash interface{}) []byte {
111+
func CryptEncoderSSHA512(salt string) func(pass []byte, hash any) []byte {
112+
return func(pass []byte, hash any) []byte {
113113
s := []byte(salt)
114114
p := append(pass, s...)
115115
h := sha512.Sum512(p)

‎sqlite3_func_crypt_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestCryptEncoders(t *testing.T) {
2929
}
3030

3131
for _, e := range tests {
32-
var fn func(pass []byte, hash interface{}) []byte
32+
var fn func(pass []byte, hash any) []byte
3333
switch e.enc {
3434
case "sha1":
3535
fn = CryptEncoderSHA1

‎sqlite3_go113_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestBeginTxCancel(t *testing.T) {
4545
}
4646
}()
4747

48-
err = conn.Raw(func(driverConn interface{}) error {
48+
err = conn.Raw(func(driverConn any) error {
4949
d, ok := driverConn.(driver.ConnBeginTx)
5050
if !ok {
5151
t.Fatal("unexpected: wrong type")
@@ -96,7 +96,7 @@ func TestStmtReadonly(t *testing.T) {
9696
}
9797

9898
var ro bool
99-
c.Raw(func(dc interface{}) error {
99+
c.Raw(func(dc any) error {
100100
stmt, err := dc.(*SQLiteConn).Prepare(query)
101101
if err != nil {
102102
return err

‎sqlite3_opt_preupdate_hook.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ func (d *SQLitePreUpdateData) Count() int {
5454
return int(C.sqlite3_preupdate_count(d.Conn.db))
5555
}
5656

57-
func (d *SQLitePreUpdateData) row(dest []interface{}, new bool) error {
57+
func (d *SQLitePreUpdateData) row(dest []any, new bool) error {
5858
for i := 0; i < d.Count() && i < len(dest); i++ {
5959
var val *C.sqlite3_value
60-
var src interface{}
60+
var src any
6161

6262
// Initially I tried making this just a function pointer argument, but
6363
// it's absurdly complicated to pass C function pointers.
@@ -95,7 +95,7 @@ func (d *SQLitePreUpdateData) row(dest []interface{}, new bool) error {
9595

9696
// Old populates dest with the row data to be replaced. This works similar to
9797
// database/sql's Rows.Scan()
98-
func (d *SQLitePreUpdateData) Old(dest ...interface{}) error {
98+
func (d *SQLitePreUpdateData) Old(dest ...any) error {
9999
if d.Op == SQLITE_INSERT {
100100
return errors.New("There is no old row for INSERT operations")
101101
}
@@ -104,7 +104,7 @@ func (d *SQLitePreUpdateData) Old(dest ...interface{}) error {
104104

105105
// New populates dest with the replacement row data. This works similar to
106106
// database/sql's Rows.Scan()
107-
func (d *SQLitePreUpdateData) New(dest ...interface{}) error {
107+
func (d *SQLitePreUpdateData) New(dest ...any) error {
108108
if d.Op == SQLITE_DELETE {
109109
return errors.New("There is no new row for DELETE operations")
110110
}

‎sqlite3_opt_preupdate_hook_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ type preUpdateHookDataForTest struct {
1818
tableName string
1919
count int
2020
op int
21-
oldRow []interface{}
22-
newRow []interface{}
21+
oldRow []any
22+
newRow []any
2323
}
2424

2525
func TestPreUpdateHook(t *testing.T) {
@@ -29,7 +29,7 @@ func TestPreUpdateHook(t *testing.T) {
2929
ConnectHook: func(conn *SQLiteConn) error {
3030
conn.RegisterPreUpdateHook(func(data SQLitePreUpdateData) {
3131
eval := -1
32-
oldRow := []interface{}{eval}
32+
oldRow := []any{eval}
3333
if data.Op != SQLITE_INSERT {
3434
err := data.Old(oldRow...)
3535
if err != nil {
@@ -38,7 +38,7 @@ func TestPreUpdateHook(t *testing.T) {
3838
}
3939

4040
eval2 := -1
41-
newRow := []interface{}{eval2}
41+
newRow := []any{eval2}
4242
if data.Op != SQLITE_DELETE {
4343
err := data.New(newRow...)
4444
if err != nil {
@@ -47,7 +47,7 @@ func TestPreUpdateHook(t *testing.T) {
4747
}
4848

4949
// tests dest bound checks in loop
50-
var tooSmallRow []interface{}
50+
var tooSmallRow []any
5151
if data.Op != SQLITE_INSERT {
5252
err := data.Old(tooSmallRow...)
5353
if err != nil {

‎sqlite3_opt_serialize_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestSerializeDeserialize(t *testing.T) {
5454
defer srcConn.Close()
5555

5656
var serialized []byte
57-
if err := srcConn.Raw(func(raw interface{}) error {
57+
if err := srcConn.Raw(func(raw any) error {
5858
var err error
5959
serialized, err = raw.(*SQLiteConn).Serialize("")
6060
return err
@@ -80,7 +80,7 @@ func TestSerializeDeserialize(t *testing.T) {
8080
}
8181
defer destConn.Close()
8282

83-
if err := destConn.Raw(func(raw interface{}) error {
83+
if err := destConn.Raw(func(raw any) error {
8484
return raw.(*SQLiteConn).Deserialize(serialized, "")
8585
}); err != nil {
8686
t.Fatal("Failed to deserialize source database:", err)

0 commit comments

Comments
 (0)
Please sign in to comment.