Skip to content

Commit

Permalink
update go version to 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Jan 25, 2024
1 parent 00b02e0 commit c91bca4
Show file tree
Hide file tree
Showing 21 changed files with 88 additions and 89 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
go: ['1.18', '1.19', '1.20']
go: ['1.19', '1.20', '1.21']
fail-fast: false
env:
OS: ${{ matrix.os }}
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:

strategy:
matrix:
go: ['1.18', '1.19', '1.20']
go: ['1.19', '1.20', '1.21']
fail-fast: false
env:
OS: windows-latest
Expand Down
6 changes: 3 additions & 3 deletions _example/limit/limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"github.com/mattn/go-sqlite3"
)

func createBulkInsertQuery(n int, start int) (query string, args []interface{}) {
func createBulkInsertQuery(n int, start int) (query string, args []any) {
values := make([]string, n)
args = make([]interface{}, n*2)
args = make([]any, n*2)
pos := 0
for i := 0; i < n; i++ {
values[i] = "(?, ?)"
Expand All @@ -27,7 +27,7 @@ func createBulkInsertQuery(n int, start int) (query string, args []interface{})
return
}

func bulkInsert(db *sql.DB, query string, args []interface{}) (err error) {
func bulkInsert(db *sql.DB, query string, args []any) (err error) {
stmt, err := db.Prepare(query)
if err != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion _example/vtable/vtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (vc *ghRepoCursor) Column(c *sqlite3.SQLiteContext, col int) error {
return nil
}

func (vc *ghRepoCursor) Filter(idxNum int, idxStr string, vals []interface{}) error {
func (vc *ghRepoCursor) Filter(idxNum int, idxStr string, vals []any) error {
vc.index = 0
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion _example/vtable_eponymous_only/vtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (vc *seriesCursor) Column(c *sqlite3.SQLiteContext, col int) error {
return nil
}

func (vc *seriesCursor) Filter(idxNum int, idxStr string, vals []interface{}) error {
func (vc *seriesCursor) Filter(idxNum int, idxStr string, vals []any) error {
switch {
case len(vals) < 1:
vc.seriesTable.start = 0
Expand Down
8 changes: 4 additions & 4 deletions callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ func preUpdateHookTrampoline(handle unsafe.Pointer, dbHandle uintptr, op int, db
// Use handles to avoid passing Go pointers to C.
type handleVal struct {
db *SQLiteConn
val interface{}
val any
}

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

func newHandle(db *SQLiteConn, v interface{}) unsafe.Pointer {
func newHandle(db *SQLiteConn, v any) unsafe.Pointer {
handleLock.Lock()
defer handleLock.Unlock()
val := handleVal{db: db, val: v}
Expand All @@ -124,7 +124,7 @@ func lookupHandleVal(handle unsafe.Pointer) handleVal {
return handleVals[handle]
}

func lookupHandle(handle unsafe.Pointer) interface{} {
func lookupHandle(handle unsafe.Pointer) any {
return lookupHandleVal(handle).val
}

Expand Down Expand Up @@ -238,7 +238,7 @@ func callbackArg(typ reflect.Type) (callbackArgConverter, error) {
switch typ.Kind() {
case reflect.Interface:
if typ.NumMethod() != 0 {
return nil, errors.New("the only supported interface type is interface{}")
return nil, errors.New("the only supported interface type is any")
}
return callbackArgGeneric, nil
case reflect.Slice:
Expand Down
4 changes: 2 additions & 2 deletions callback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestCallbackArgCast(t *testing.T) {

func TestCallbackConverters(t *testing.T) {
tests := []struct {
v interface{}
v any
err bool
}{
// Unfortunately, we can't tell which converter was returned,
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestCallbackConverters(t *testing.T) {
}

func TestCallbackReturnAny(t *testing.T) {
udf := func() interface{} {
udf := func() any {
return 1
}

Expand Down
10 changes: 5 additions & 5 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var errNilPtr = errors.New("destination pointer is nil") // embedded in descript
// convertAssign copies to dest the value in src, converting it if possible.
// An error is returned if the copy would result in loss of information.
// dest should be a pointer type.
func convertAssign(dest, src interface{}) error {
func convertAssign(dest, src any) error {
// Common cases, without reflect.
switch s := src.(type) {
case string:
Expand Down Expand Up @@ -55,7 +55,7 @@ func convertAssign(dest, src interface{}) error {
}
*d = string(s)
return nil
case *interface{}:
case *any:
if d == nil {
return errNilPtr
}
Expand Down Expand Up @@ -97,7 +97,7 @@ func convertAssign(dest, src interface{}) error {
}
case nil:
switch d := dest.(type) {
case *interface{}:
case *any:
if d == nil {
return errNilPtr
}
Expand Down Expand Up @@ -149,7 +149,7 @@ func convertAssign(dest, src interface{}) error {
*d = bv.(bool)
}
return err
case *interface{}:
case *any:
*d = src
return nil
}
Expand Down Expand Up @@ -256,7 +256,7 @@ func cloneBytes(b []byte) []byte {
return c
}

func asString(src interface{}) string {
func asString(src any) string {
switch v := src.(type) {
case string:
return v
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ You can also use database/sql.Conn.Raw (Go >= 1.13):
conn, err := db.Conn(context.Background())
// if err != nil { ... }
defer conn.Close()
err = conn.Raw(func (driverConn interface{}) error {
err = conn.Raw(func (driverConn any) error {
sqliteConn := driverConn.(*sqlite3.SQLiteConn)
// ... use sqliteConn
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mattn/go-sqlite3

go 1.16
go 1.19

retract (
[v2.0.0+incompatible, v2.0.6+incompatible] // Accidental; no major changes or features.
Expand Down
11 changes: 5 additions & 6 deletions sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,9 @@ func (c *SQLiteConn) RegisterAuthorizer(callback func(int, string, string, strin
// RegisterFunc makes a Go function available as a SQLite function.
//
// The Go function can have arguments of the following types: any
// numeric type except complex, bool, []byte, string and
// interface{}. interface{} arguments are given the direct translation
// of the SQLite data type: int64 for INTEGER, float64 for FLOAT,
// []byte for BLOB, string for TEXT.
// numeric type except complex, bool, []byte, string and any.
// any arguments are given the direct translation of the SQLite data type:
// int64 for INTEGER, float64 for FLOAT, []byte for BLOB, string for TEXT.
//
// The function can additionally be variadic, as long as the type of
// the variadic argument is one of the above.
Expand All @@ -620,7 +619,7 @@ func (c *SQLiteConn) RegisterAuthorizer(callback func(int, string, string, strin
// optimizations in its queries.
//
// See _example/go_custom_funcs for a detailed example.
func (c *SQLiteConn) RegisterFunc(name string, impl interface{}, pure bool) error {
func (c *SQLiteConn) RegisterFunc(name string, impl any, pure bool) error {
var fi functionInfo
fi.f = reflect.ValueOf(impl)
t := fi.f.Type()
Expand Down Expand Up @@ -702,7 +701,7 @@ func sqlite3CreateFunction(db *C.sqlite3, zFunctionName *C.char, nArg C.int, eTe
// return an error in addition to their other return values.
//
// See _example/go_custom_funcs for a detailed example.
func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool) error {
func (c *SQLiteConn) RegisterAggregator(name string, impl any, pure bool) error {
var ai aggInfo
ai.constructor = reflect.ValueOf(impl)
t := ai.constructor.Type()
Expand Down
24 changes: 12 additions & 12 deletions sqlite3_func_crypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ import (
// perhaps using a cryptographic hash function like SHA1.

// CryptEncoderSHA1 encodes a password with SHA1
func CryptEncoderSHA1(pass []byte, hash interface{}) []byte {
func CryptEncoderSHA1(pass []byte, hash any) []byte {
h := sha1.Sum(pass)
return h[:]
}

// CryptEncoderSSHA1 encodes a password with SHA1 with the
// configured salt.
func CryptEncoderSSHA1(salt string) func(pass []byte, hash interface{}) []byte {
return func(pass []byte, hash interface{}) []byte {
func CryptEncoderSSHA1(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash any) []byte {
s := []byte(salt)
p := append(pass, s...)
h := sha1.Sum(p)
Expand All @@ -67,15 +67,15 @@ func CryptEncoderSSHA1(salt string) func(pass []byte, hash interface{}) []byte {
}

// CryptEncoderSHA256 encodes a password with SHA256
func CryptEncoderSHA256(pass []byte, hash interface{}) []byte {
func CryptEncoderSHA256(pass []byte, hash any) []byte {
h := sha256.Sum256(pass)
return h[:]
}

// CryptEncoderSSHA256 encodes a password with SHA256
// with the configured salt
func CryptEncoderSSHA256(salt string) func(pass []byte, hash interface{}) []byte {
return func(pass []byte, hash interface{}) []byte {
func CryptEncoderSSHA256(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash any) []byte {
s := []byte(salt)
p := append(pass, s...)
h := sha256.Sum256(p)
Expand All @@ -84,15 +84,15 @@ func CryptEncoderSSHA256(salt string) func(pass []byte, hash interface{}) []byte
}

// CryptEncoderSHA384 encodes a password with SHA384
func CryptEncoderSHA384(pass []byte, hash interface{}) []byte {
func CryptEncoderSHA384(pass []byte, hash any) []byte {
h := sha512.Sum384(pass)
return h[:]
}

// CryptEncoderSSHA384 encodes a password with SHA384
// with the configured salt
func CryptEncoderSSHA384(salt string) func(pass []byte, hash interface{}) []byte {
return func(pass []byte, hash interface{}) []byte {
func CryptEncoderSSHA384(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash any) []byte {
s := []byte(salt)
p := append(pass, s...)
h := sha512.Sum384(p)
Expand All @@ -101,15 +101,15 @@ func CryptEncoderSSHA384(salt string) func(pass []byte, hash interface{}) []byte
}

// CryptEncoderSHA512 encodes a password with SHA512
func CryptEncoderSHA512(pass []byte, hash interface{}) []byte {
func CryptEncoderSHA512(pass []byte, hash any) []byte {
h := sha512.Sum512(pass)
return h[:]
}

// CryptEncoderSSHA512 encodes a password with SHA512
// with the configured salt
func CryptEncoderSSHA512(salt string) func(pass []byte, hash interface{}) []byte {
return func(pass []byte, hash interface{}) []byte {
func CryptEncoderSSHA512(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash any) []byte {
s := []byte(salt)
p := append(pass, s...)
h := sha512.Sum512(p)
Expand Down
2 changes: 1 addition & 1 deletion sqlite3_func_crypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestCryptEncoders(t *testing.T) {
}

for _, e := range tests {
var fn func(pass []byte, hash interface{}) []byte
var fn func(pass []byte, hash any) []byte
switch e.enc {
case "sha1":
fn = CryptEncoderSHA1
Expand Down
4 changes: 2 additions & 2 deletions sqlite3_go113_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestBeginTxCancel(t *testing.T) {
}
}()

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

var ro bool
c.Raw(func(dc interface{}) error {
c.Raw(func(dc any) error {
stmt, err := dc.(*SQLiteConn).Prepare(query)
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions sqlite3_opt_preupdate_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ func (d *SQLitePreUpdateData) Count() int {
return int(C.sqlite3_preupdate_count(d.Conn.db))
}

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

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

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

// New populates dest with the replacement row data. This works similar to
// database/sql's Rows.Scan()
func (d *SQLitePreUpdateData) New(dest ...interface{}) error {
func (d *SQLitePreUpdateData) New(dest ...any) error {
if d.Op == SQLITE_DELETE {
return errors.New("There is no new row for DELETE operations")
}
Expand Down
10 changes: 5 additions & 5 deletions sqlite3_opt_preupdate_hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type preUpdateHookDataForTest struct {
tableName string
count int
op int
oldRow []interface{}
newRow []interface{}
oldRow []any
newRow []any
}

func TestPreUpdateHook(t *testing.T) {
Expand All @@ -29,7 +29,7 @@ func TestPreUpdateHook(t *testing.T) {
ConnectHook: func(conn *SQLiteConn) error {
conn.RegisterPreUpdateHook(func(data SQLitePreUpdateData) {
eval := -1
oldRow := []interface{}{eval}
oldRow := []any{eval}
if data.Op != SQLITE_INSERT {
err := data.Old(oldRow...)
if err != nil {
Expand All @@ -38,7 +38,7 @@ func TestPreUpdateHook(t *testing.T) {
}

eval2 := -1
newRow := []interface{}{eval2}
newRow := []any{eval2}
if data.Op != SQLITE_DELETE {
err := data.New(newRow...)
if err != nil {
Expand All @@ -47,7 +47,7 @@ func TestPreUpdateHook(t *testing.T) {
}

// tests dest bound checks in loop
var tooSmallRow []interface{}
var tooSmallRow []any
if data.Op != SQLITE_INSERT {
err := data.Old(tooSmallRow...)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions sqlite3_opt_serialize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestSerializeDeserialize(t *testing.T) {
defer srcConn.Close()

var serialized []byte
if err := srcConn.Raw(func(raw interface{}) error {
if err := srcConn.Raw(func(raw any) error {
var err error
serialized, err = raw.(*SQLiteConn).Serialize("")
return err
Expand All @@ -80,7 +80,7 @@ func TestSerializeDeserialize(t *testing.T) {
}
defer destConn.Close()

if err := destConn.Raw(func(raw interface{}) error {
if err := destConn.Raw(func(raw any) error {
return raw.(*SQLiteConn).Deserialize(serialized, "")
}); err != nil {
t.Fatal("Failed to deserialize source database:", err)
Expand Down
Loading

0 comments on commit c91bca4

Please sign in to comment.