-
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
toolchain: Minimal version selection applies to indirect dependencies even when they are module-local #69798
Comments
this looks working as intended, MVS applies to modules and not packages. modules need to declare different names in their go.mod Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For questions please refer to https://github.com/golang/go/wiki/Questions |
hmm right, that's why I am surprised that it appears to apply to packages in this case, and that looks as a bug to me. |
EDIT: I am removing the reference to internal packages, because it's misleading. |
I have slightly changed the example to highlight the suspicious behaviour. The module is correctly fetched, but subpackages of the modules are fetched by name without namespacing them to the module. Reproducer: https://go.dev/play/p/1OD7Zm41iMM
Whereas it should have been:
The modules aliased as "old" and "new" are correctly fetched, but the subpackage of "NEW " should have said "I am new". Instead, the Are you sure that mixing packages from different modules really is the intended behaviour? That is surprising enough to look like a bug to me. |
They both import the same package replace directives do not allow you to rename an entire module, it only changes the source code location. |
If the module name of |
Why it doesn't compile is probably related to #50278 |
From the perspective of the module in the In my honest opinion, the compiler should report a (This is just one pitfall of the current module system design. There are some others.) |
The code (https://go.dev/play/p/VLhjzQtcbD3) works as OP's intention in an unexpected way. (It proves that how the modules are named in the |
This issue proves that relative import paths are necessary in the module system. |
I suggest to re-open this issue, with a different title: a dependency module A should not use the packages in another dependency module B if A's go.mod file doesn't require B. |
go.mod files may be incomplete, for example from before indirect dependencies were added to go.mod |
What you described and I described are two things. In the OP's case, |
Go version
go version go1.23.2 linux/amd64
Output of
go env
in your module/workspace:What did you do?
The background
While preparing a new version of my library, I am testing the interactions between the old version (
v2
) and the new version I am working on (v3
). I want to import them both, using local rewrites in my localgo.mod
. The caveat: there is nov3
yet, so internally the imports of both versions are identical.The actual issue
This is the most minimal reproducer I could produce: https://go.dev/play/p/Up68jxuX6_v
This might help understanding the directory structure of the example in the sandbox:
There is a package main that imports both
old
andnew
. Bothold
andnew
contain exactly the same code, and they both import a sub-packagesub
. The content of those twosub
packages is different: one saysI am old
, the other saysI am new
.Both imports are resolved to
old/sub
.I find it surprising that imports within a module are not rewritten when a module is imported as a rewrite. I expected
package_new.Speak()
to printI am new
, becausepackage_new
importssub
from within its own module, and I have rewritten the import of that module.What did you see happen?
What did you expect to see?
The text was updated successfully, but these errors were encountered: