I recently found myself doing the following in one of our test suites
func Foo[T testing.T | testing.B | testing.F](t *T) *Bar {
// test prep stuff
var cleanupFn func(func())
switch any(t).(type) {
case *testing.T:
cleanupFn = any(t).(*testing.T).Cleanup
case *testing.B:
cleanupFn = any(t).(*testing.B).Cleanup
case *testing.F:
cleanupFn = any(t).(*testing.F).Cleanup
default:
log.Fatalf("Error: unsupported type %T", t)
}
cleanupFn(func(){
// test cleanup stuff
})
The cleanup function is common to all of these and is part of the common struct, which is embedded in each of testingT, testing.B, and testing.F.

I was wondering if common could potentially be exposed as an interface?
I'm happy to take a first stab at the PR if this is something the library mainteras would be open to, unless there's a technical reason this shouldn't be the case. Please lmk!
I recently found myself doing the following in one of our test suites
The cleanup function is common to all of these and is part of the
commonstruct, which is embedded in each oftestingT,testing.B, andtesting.F.I was wondering if
commoncould potentially be exposed as an interface?I'm happy to take a first stab at the PR if this is something the library mainteras would be open to, unless there's a technical reason this shouldn't be the case. Please lmk!