-
Notifications
You must be signed in to change notification settings - Fork 17.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: Types and Functions defined in _test.go files are not visible/exported #10184
Comments
Ok, upon going through the code, I found these two places: https://github.com/golang/go/blob/master/src/cmd/go/build.go#L949 _test.go files are not included in coverage. Fine but is it possible that go install/build can be trained to throw a more verbose error message? For example: Definition found in xxx_test.go, please change the file name to something other than xxx_test.go |
Apparently this issue has the side effect of resulting in inconsistent test runs whether you run Namely, if you run This usually never happens because people tend to run /cc @hatchan |
Working as intended. The *_test.go files are compiled into the package only when running go test for that package. |
Go version 1.4.2 release
OS: Linux amd64
The go install command doesn't pick up structs and functions which are defined in source file with names xxx_test.go
I know go test command uses _test.go files as part of the built in testing framework. In case I am building a lib, and I write tests in _test.go files (define some functions etc.) and run them from package main, but at present those definitions won't be visible and go install throws an error: undefined: TypeName
Is it possible that go install/build can be trained to throw a more verbose error message: For example: Definition found in xxx_test.go, please change the file name to something other than xxx_test.go
The text was updated successfully, but these errors were encountered: