diff options
| author | Russ Cox <rsc@golang.org> | 2021-12-01 12:15:45 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2021-12-13 18:45:54 +0000 |
| commit | 2580d0e08d5e9f979b943758d3c49877fb2324cb (patch) | |
| tree | 3aafccfd81087734156a1778ce2321adf345f271 /src/database/sql/convert_test.go | |
| parent | 083ef5462494e81ee23316245c5d65085a3f62d9 (diff) | |
| download | go-2580d0e08d5e9f979b943758d3c49877fb2324cb.tar.xz | |
all: gofmt -w -r 'interface{} -> any' src
And then revert the bootstrap cmd directories and certain testdata.
And adjust tests as needed.
Not reverting the changes in std that are bootstrapped,
because some of those changes would appear in API docs,
and we want to use any consistently.
Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories
when preparing the bootstrap copy.
A few files changed as a result of running gofmt -w
not because of interface{} -> any but because they
hadn't been updated for the new //go:build lines.
Fixes #49884.
Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09
Reviewed-on: https://go-review.googlesource.com/c/go/+/368254
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/database/sql/convert_test.go')
| -rw-r--r-- | src/database/sql/convert_test.go | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/database/sql/convert_test.go b/src/database/sql/convert_test.go index 400da7ea57..6d09fa1eae 100644 --- a/src/database/sql/convert_test.go +++ b/src/database/sql/convert_test.go @@ -25,7 +25,7 @@ type ( ) type conversionTest struct { - s, d interface{} // source and destination + s, d any // source and destination // following are used if they're non-zero wantint int64 @@ -38,7 +38,7 @@ type conversionTest struct { wanttime time.Time wantbool bool // used if d is of type *bool wanterr string - wantiface interface{} + wantiface any wantptr *int64 // if non-nil, *d's pointed value must be equal to *wantptr wantnil bool // if true, *d must be *int64(nil) wantusrdef userDefined @@ -58,7 +58,7 @@ var ( scanf64 float64 scantime time.Time scanptr *int64 - scaniface interface{} + scaniface any ) func conversionTests() []conversionTest { @@ -161,7 +161,7 @@ func conversionTests() []conversionTest { {s: "1.5", d: &scanf64, wantf64: float64(1.5)}, // Pointers - {s: interface{}(nil), d: &scanptr, wantnil: true}, + {s: any(nil), d: &scanptr, wantnil: true}, {s: int64(42), d: &scanptr, wantptr: &answer}, // To interface{} @@ -185,27 +185,27 @@ func conversionTests() []conversionTest { } } -func intPtrValue(intptr interface{}) interface{} { +func intPtrValue(intptr any) any { return reflect.Indirect(reflect.Indirect(reflect.ValueOf(intptr))).Int() } -func intValue(intptr interface{}) int64 { +func intValue(intptr any) int64 { return reflect.Indirect(reflect.ValueOf(intptr)).Int() } -func uintValue(intptr interface{}) uint64 { +func uintValue(intptr any) uint64 { return reflect.Indirect(reflect.ValueOf(intptr)).Uint() } -func float64Value(ptr interface{}) float64 { +func float64Value(ptr any) float64 { return *(ptr.(*float64)) } -func float32Value(ptr interface{}) float32 { +func float32Value(ptr any) float32 { return *(ptr.(*float32)) } -func timeValue(ptr interface{}) time.Time { +func timeValue(ptr any) time.Time { return *(ptr.(*time.Time)) } @@ -216,7 +216,7 @@ func TestConversions(t *testing.T) { if err != nil { errstr = err.Error() } - errf := func(format string, args ...interface{}) { + errf := func(format string, args ...any) { base := fmt.Sprintf("convertAssign #%d: for %v (%T) -> %T, ", n, ct.s, ct.s, ct.d) t.Errorf(base+format, args...) } @@ -260,7 +260,7 @@ func TestConversions(t *testing.T) { errf("want pointer to %v, got %v", *ct.wantptr, intPtrValue(ct.d)) } } - if ifptr, ok := ct.d.(*interface{}); ok { + if ifptr, ok := ct.d.(*any); ok { if !reflect.DeepEqual(ct.wantiface, scaniface) { errf("want interface %#v, got %#v", ct.wantiface, scaniface) continue @@ -301,7 +301,7 @@ func TestNullString(t *testing.T) { type valueConverterTest struct { c driver.ValueConverter - in, out interface{} + in, out any err string } @@ -335,7 +335,7 @@ func TestValueConverters(t *testing.T) { func TestRawBytesAllocs(t *testing.T) { var tests = []struct { name string - in interface{} + in any want string }{ {"uint64", uint64(12345678), "12345678"}, @@ -355,7 +355,7 @@ func TestRawBytesAllocs(t *testing.T) { } buf := make(RawBytes, 10) - test := func(name string, in interface{}, want string) { + test := func(name string, in any, want string) { if err := convertAssign(&buf, in); err != nil { t.Fatalf("%s: convertAssign = %v", name, err) } @@ -430,11 +430,11 @@ func TestDriverArgs(t *testing.T) { var nilValuerPPtr *Valuer_P var nilStrPtr *string tests := []struct { - args []interface{} + args []any want []driver.NamedValue }{ 0: { - args: []interface{}{Valuer_V("foo")}, + args: []any{Valuer_V("foo")}, want: []driver.NamedValue{ { Ordinal: 1, @@ -443,7 +443,7 @@ func TestDriverArgs(t *testing.T) { }, }, 1: { - args: []interface{}{nilValuerVPtr}, + args: []any{nilValuerVPtr}, want: []driver.NamedValue{ { Ordinal: 1, @@ -452,7 +452,7 @@ func TestDriverArgs(t *testing.T) { }, }, 2: { - args: []interface{}{nilValuerPPtr}, + args: []any{nilValuerPPtr}, want: []driver.NamedValue{ { Ordinal: 1, @@ -461,7 +461,7 @@ func TestDriverArgs(t *testing.T) { }, }, 3: { - args: []interface{}{"plain-str"}, + args: []any{"plain-str"}, want: []driver.NamedValue{ { Ordinal: 1, @@ -470,7 +470,7 @@ func TestDriverArgs(t *testing.T) { }, }, 4: { - args: []interface{}{nilStrPtr}, + args: []any{nilStrPtr}, want: []driver.NamedValue{ { Ordinal: 1, |
