Open fxrlv opened 3 months ago
cc @matloob
I might be misunderstanding the bug report but I'm not sure I see the inconsistency.
The intention of the driverRequest doc is not to say that the path has to be absolute, but that relative paths are interpreted relative to the driver's working directory. Maybe we can be more clear and explicitly state that the path can be absolute?
Oh, I see. Very first looking at the doc I thought that paths are supposed to be relative and that is the reason why that mark about driver’s workdir is there.
Having that paths can be both relative and absolute it’s unclear what’s expected behavior when one path is listed twice in both forms. Maybe it’s also worth mentioning. What do you think?
I wouldn't mind if we added a clarifying comment. Using the default cmd/go driver it's an error to provide two paths that canonicalize to the same path in an overlay (https://cs.opensource.google/go/go/+/647870becc230b022b431a4ef8b7c9b31382db6c:src/cmd/go/internal/fsys/fsys.go;l=204)
Feel free to send a CL
Go version
go version go1.22.3 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
https://pkg.go.dev/golang.org/x/tools/go/packages#DriverRequest
https://pkg.go.dev/golang.org/x/tools/go/packages#Config
The DriverRequest's documentation states that paths are relative meanwhile Config's documentation states the opposite. There is no problem here but little inconsistency.
What did you see happen?
The next driver invocation that happens inside
packages.Load(...)
totally violates the path convention the documentation set.https://github.com/golang/tools/blob/c3aae998cf1d05bd3465e576730c67a9df71b4fa/go/packages/external.go#L112
cfg.Overlay
is not changed anywhere before. So on the left side there should be relative paths, on the other in fact absolute paths.That is what a gopackagesdriver actually gets. Minimal repro looks like the following.
This driver is throwing an error that contains an absolute path.
What did you expect to see?
I expect the docs should not be misleading.
I think there is no reason for a driver to operate with relative paths. So I would propose to fix the docs instead of changing the
packages.Load(...)
behavior.