Open dolmen opened 3 months ago
I am not sure this is a bug, there is in fact no main function in the main package. Not-module-mode is now a special case, at least as I understand it.
@rsc (for go/build) and @golang/tools-team (for the playground).
Reproducible builds on the Go playground (enforced by locking dependencies with go.mod) are an important feature (even if still underused) to help bug reporters to demonstrate issues. A func(*testing.T)
is a good way to convey that as the code provided can easily be integrated in a test suite.
This may not qualify as "bug" but "feature request" or "proposal", but I argue it is an important feature for the Go community.
On the bottom of go.dev/play
it says
If the program contains tests or examples and no main function, the service runs the tests.
It sounds like we should either support this or update that text to make it clear it's not supported in module mode?
On the issue of reproducibility, it's harder to guarantee that what's on the playground is reproducible. The playground runs the build with -mod=mod
which will pull in dependencies that are missing from an untidy go.mod and will set the module's go version (which controls language semantics) to the version of the go command that's running.
func Test(*testing.T)
is not executed on https://go.dev/play when a go.mod file is provided.What did you do?
This doesn't run: https://go.dev/play/p/ZDFf4aGucoB
What did you see happen?
Output:
What did you expect to see?
If I remove the
go.mod
, it runs correctly.Example: https://go.dev/play/p/AsRNcxCRdWx