-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
doc: clarify the interaction between modules and synthesized packages #46434
Comments
When cd /abs/path/to
go build /abs/path/to/file.go fails with:
If I add a
If If this is the intended behavior, it should be documented. |
@bcmills do you think this is a possible issue for cmd/go implementation? go run /abs/path/to/file.go also fail with the same error
But I think the error message is confusing, since in this case In this case
or it should synthesize a |
https://golang.org/cmd/go/#hdr-The_go_mod_file says
The suggested command is the correct one for the previous one ( synthesized module with dependencies for run is #42088 |
There are two problems:
Thanks. |
I don't see why 2 is a problem, a package is synthesized and run in the context of the current module, and it's an error if the current/main module doesn't provide all the necessary dependencies |
IMHO, 2 is a problem for the same reason why |
|
Yes, I was thinking of
I think that something similar should also apply to a synthesized package. The main problem with a synthesized package is that it currently uses the Thanks. |
Reading the source code of |
Another possible confusing error. When a non existing go run /abs/path/to/nofile.go
|
The behavior of the |
I have noted another unusual behavior with synthesized modules. From inside the It is the same with: |
Sorry, forget the last comment. I had a |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The
packages
help topic (go help packages
or https://golang.org/pkg/cmd/go/#hdr-Package_lists_and_patterns), says:The following command, as an example, works
The problem is that, in module mode, a package must belong to a module, so in theory
go build
should fail as incd /abs/path/to go build
The documentation should say that a module is also synthesized.
The text was updated successfully, but these errors were encountered: