-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: 'go test' does not reject a relative path spanning a module boundary #30992
Comments
Seems this should be an error? At least, that would be my personal expectation... CC @jayconrod |
https://golang.org/cmd/go/#hdr-The_main_module_and_the_build_list says:
So, when you're in It seems like the behavior is very unintuitive when the go command is run in one module, but but the package specified on the command line is outside of that module. |
I agree this is a bug and we should show an error for it. File system paths (including relative paths) are allowed to reference directories in the main module and in other modules in the build list. Without a file system |
It's not the presence in |
It is legal and has no effect. We are considering removing ineffective directives in |
Change https://golang.org/cl/185345 mentions this issue: |
In golang.org/x/exp there's a golang.org/x/exp/notary submodule.
I was making changes in golang.org/x/exp/notary/internal/note, and I ran the tests as
go test ./notary/internal/note
. If it weren't for the fact that my cache was missing some modules, leading to ago: extracting golang.org/x/exp/notary
message, I would not have known I was testing the upstream code downloaded from the Internet instead of the new code on my machine.Even worse, you could imagine running
go build
orgo install
with the same relative path, and the changes on disk wouldn't be reflected, which sounds a lot like the most frustrating experiences I've had with some web development setups.There is a solution to this which is to add a
replace
directive in the golang.org/x/exp go.mod pointing to./notary
, but I don't even know if an unusedreplace
is legal or effective. And anyway, it feels like something most projects will only discover painfully.(There was one other sign that something went wrong: golang.org/x/exp/notary showed up in the golang.org/x/exp go.mod file, but that would not have happened if it were already there. In that case it should really have had a
replace
, because otherwise a similar issue would happen with golang.org/x/exp using the unmodified dependency, but again, this is a painful default and it's not clear how one is supposed to learn about the solution.)/cc @bcmills
The text was updated successfully, but these errors were encountered: