Can't run go tests from GoLand (Intellij Idea): compilation failed

已回答

I've made simple application in go and trying to run tests with GUI tools of GoLand.

In myfile_test.go file near test func I press green button that should start test. But I get error message: "Compilation failed" and message in console:

# command-line-arguments [command-line-arguments.test]
./myfile_test.go:21:11: undefined: MyStruct
./myfile_test.go:22:12: undefined: MyFuncName
./myfile_test.go:33:12: undefined: AnotherStruct

Compilation finished with exit code 2

Other variants (Run test with Coverage/CPU Profile) don't work either. GoLand 2020.1 EAP. The same problem occurred in older versions of GoLand mycardstatement .

But test from console starts normally:

go test -v

=== RUN   TestMyStruct_MyMethod
--- PASS: TestMyStruct_MyMethod (0.00s)
PASS
ok      _/home/username/projects/my_project_name     0.002s
1

Hello,

Could you please share a code snippet to reproduce the issue?

Also, you can try to use the 2021.1.3 version (https://www.jetbrains.com/go/download) or the EAP version (https://www.jetbrains.com/go/nextversion/).

0

请先登录再写评论。