diff --git a/autogold.go b/autogold.go index f09c056..400d5cc 100644 --- a/autogold.go +++ b/autogold.go @@ -45,7 +45,7 @@ func update() bool { // // If the input value is of type Raw, its contents will be directly used instead of the value being // formatted as a Go literal. -func ExpectFile(t *testing.T, got interface{}, opts ...Option) { +func ExpectFile(t *testing.T, got any, opts ...Option) { t.Helper() dir := testdataDir(opts) fileName := testName(t, opts) diff --git a/diff.go b/diff.go index a954513..2992c68 100644 --- a/diff.go +++ b/diff.go @@ -17,7 +17,7 @@ func diff(got, want string, opts []Option) string { // Raw denotes a raw string. type Raw string -func stringify(v interface{}, opts []Option) string { +func stringify(v any, opts []Option) string { var ( allowRaw, trailingNewline bool valastOpt = &valast.Options{} diff --git a/expect.go b/expect.go index b7c6f50..89f03ae 100644 --- a/expect.go +++ b/expect.go @@ -24,15 +24,15 @@ import ( // Value describes a desired value for a Go test, see Expect for more information. type Value interface { // Equal checks if `got` matches the desired test value, invoking t.Fatal otherwise. - Equal(t *testing.T, got interface{}, opts ...Option) + Equal(t *testing.T, got any, opts ...Option) } type value struct { line int - equal func(t *testing.T, got interface{}, opts ...Option) + equal func(t *testing.T, got any, opts ...Option) } -func (v value) Equal(t *testing.T, got interface{}, opts ...Option) { +func (v value) Equal(t *testing.T, got any, opts ...Option) { t.Helper() v.equal(t, got, opts...) } @@ -88,11 +88,11 @@ find: // When `-update` is specified, autogold will find and replace in the test file by looking for an // invocation of `autogold.Expect(...)` at the same line as the callstack indicates for this function // call, rewriting the `want` value parameter for you. -func Expect(want interface{}) Value { +func Expect(want any) Value { _, _, line, _ := runtime.Caller(1) return value{ line: line, - equal: func(t *testing.T, got interface{}, opts ...Option) { + equal: func(t *testing.T, got any, opts ...Option) { t.Helper() var ( profGetPackageNameAndPath time.Duration diff --git a/expect_test.go b/expect_test.go index e1db47b..cc295ee 100644 --- a/expect_test.go +++ b/expect_test.go @@ -163,7 +163,6 @@ func Test_replaceExpect_multiple(t *testing.T) { } for _, r := range replacements { - r := r _, err := replaceExpect(t, tmpFile, r.testName, r.line, r.replacement, true) if err != nil { t.Log("\ngot:\n", err, "\nwant:\n", err) @@ -244,7 +243,6 @@ func testEqualSubtestSameNames(t *testing.T) { } for _, name := range testTable { - name := name t.Run(name, func(t *testing.T) { // Subtests are intentionally not run in parallel, as that makes this issue more easily reproducible diff --git a/parallel_test.go b/parallel_test.go index 975228c..81de2d3 100644 --- a/parallel_test.go +++ b/parallel_test.go @@ -23,7 +23,6 @@ func testParallel(t *testing.T, prefix string) { } for _, name := range testTable { - name := name t.Run(name, func(t *testing.T) { t.Parallel()