testify icon indicating copy to clipboard operation
testify copied to clipboard

[BUG] assert.New() is broken on go1.8

Open tubzby opened this issue 3 years ago • 9 comments

func TestFunc(t *testing.T) {
	assert := assert.New(t)
}

Error message:

[compiler InvalidIfaceAssign] [E] cannot use t (variable of type *testing.T) as assert.TestingT value in argument to assert.New: wrong type for method Errorf (have func(format string, args ...invalid type), want func(format string, args ...interface{}))

tubzby avatar Mar 17 '22 00:03 tubzby

Same for require pkg

cannot use t (variable of type *testing.T) as require.TestingT value in argument to require.Equal: wrong type for method Errorf (have func(format string, args ...invalid type), want func(format string, args ...interface{}))compiler[InvalidIfaceAssign](https://pkg.go.dev/golang.org/x/tools/internal/typesinternal?utm_source%3Dgopls#InvalidIfaceAssign)

go version go1.18 darwin/amd64 golang.org/x/tools/gopls v0.8.1

=== upd ===

the next day it somehow worked, although the versions did not change.

luckytea avatar Mar 17 '22 15:03 luckytea

Same here.

Guilospanck avatar Mar 17 '22 19:03 Guilospanck

Works on 1.18 for me. Are you sure your editors are updated correctly? This looks like #1138 again.

brackendawson avatar Mar 17 '22 22:03 brackendawson

Yeah, for me now it's ok. Maybe vscode was taking time to update. But now there are no errors.

Guilospanck avatar Mar 17 '22 22:03 Guilospanck

After upgrading my gopls to v0.8.1, no more error.

tubzby avatar Mar 18 '22 01:03 tubzby

you need to re-compile or update gopls with go1.18. If you are using Homebrew to install gopls, run brew reinstall gopls --install-from-sources.

jan-xyz avatar Mar 21 '22 10:03 jan-xyz

For me, It fixed my VSCode using CMD + SHIFT + P -> Go: Install/Update Tools

muzfr7 avatar Mar 31 '22 13:03 muzfr7

I am gettiing a similar type of error when i try to run linters on my code using a pipeline.

KEdore avatar Apr 04 '22 16:04 KEdore

For me, It fixed my VSCode using CMD + SHIFT + P -> Go: Install/Update Tools

That's my kind of fix: 3k errors to zero errors with one click!

ckapilla avatar Apr 30 '22 22:04 ckapilla

This discussion doesn't seem relevant anymore. Closing.

dolmen avatar Jul 25 '23 04:07 dolmen