Skip to content

Commit

Permalink
replace interface{} with any (#1561)
Browse files Browse the repository at this point in the history
  • Loading branch information
methane authored Mar 16, 2024
1 parent 33b7747 commit 33fa6e5
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 67 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ It's possible to access the last inserted ID and number of affected rows for mul

```go
conn, _ := db.Conn(ctx)
conn.Raw(func(conn interface{}) error {
conn.Raw(func(conn any) error {
ex := conn.(driver.Execer)
res, err := ex.Exec(`
UPDATE point SET x = 1 WHERE y = 2;
Expand Down
116 changes: 58 additions & 58 deletions driver_test.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ var defaultLogger = Logger(log.New(os.Stderr, "[mysql] ", log.Ldate|log.Ltime|lo

// Logger is used to log critical error messages.
type Logger interface {
Print(v ...interface{})
Print(v ...any)
}

// NopLogger is a nop implementation of the Logger interface.
type NopLogger struct{}

// Print implements Logger interface.
func (nl *NopLogger) Print(_ ...interface{}) {}
func (nl *NopLogger) Print(_ ...any) {}

// SetLogger is used to set the default logger for critical errors.
// The initial logger is os.Stderr.
Expand Down
2 changes: 1 addition & 1 deletion fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ var (
scanTypeString = reflect.TypeOf("")
scanTypeNullString = reflect.TypeOf(sql.NullString{})
scanTypeBytes = reflect.TypeOf([]byte{})
scanTypeUnknown = reflect.TypeOf(new(interface{}))
scanTypeUnknown = reflect.TypeOf(new(any))
)

type mysqlField struct {
Expand Down
2 changes: 1 addition & 1 deletion nulltime.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type NullTime sql.NullTime
// Scan implements the Scanner interface.
// The value type must be time.Time or string / []byte (formatted time-string),
// otherwise Scan fails.
func (nt *NullTime) Scan(value interface{}) (err error) {
func (nt *NullTime) Scan(value any) (err error) {
if value == nil {
nt.Time, nt.Valid = time.Time{}, false
return
Expand Down
2 changes: 1 addition & 1 deletion nulltime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (

func TestScanNullTime(t *testing.T) {
var scanTests = []struct {
in interface{}
in any
error bool
valid bool
time time.Time
Expand Down
2 changes: 1 addition & 1 deletion statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ type converter struct{}
// implementation does not. This function should be kept in sync with
// database/sql/driver defaultConverter.ConvertValue() except for that
// deliberate difference.
func (c converter) ConvertValue(v interface{}) (driver.Value, error) {
func (c converter) ConvertValue(v any) (driver.Value, error) {
if driver.IsValue(v) {
return v, nil
}
Expand Down
4 changes: 2 additions & 2 deletions statement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestConvertPointer(t *testing.T) {
}

func TestConvertSignedIntegers(t *testing.T) {
values := []interface{}{
values := []any{
int8(-42),
int16(-42),
int32(-42),
Expand Down Expand Up @@ -106,7 +106,7 @@ func (u myUint64) Value() (driver.Value, error) {
}

func TestConvertUnsignedIntegers(t *testing.T) {
values := []interface{}{
values := []any{
uint8(42),
uint16(42),
uint32(42),
Expand Down

0 comments on commit 33fa6e5

Please sign in to comment.