You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for the NeedDeps field is unclear. It says:
// NeedDeps adds the fields requested by the LoadMode in the packages in Imports.
I think perhaps the idea might be more clearly expressed as:
// NeedDeps causes all Packages transitively reachable through
// the Imports map to also be populated according to the LoadMode.
but that isn't what actually happens. Observe:
xtools$ cat main.go
package main
import (
"fmt"
"log"
"golang.org/x/tools/go/packages"
)
func main() {
cfg := &packages.Config{
Mode: packages.NeedImports |
packages.NeedCompiledGoFiles |
//packages.NeedDeps | // try with and without this line
0,
}
pkgs, err := packages.Load(cfg, "runtime")
if err != nil {
log.Fatalf("load: %v", err)
}
packages.Visit(pkgs, nil, func(p *packages.Package) {
fmt.Println(p, len(p.CompiledGoFiles))
})
}
xtools$ go run ./main.go > with
# Now uncomment the NeedDeps line.
xtools$ go run ./main.go > without
xtools$ diff with without
xtools$
# nothing
In other words, the NeedDeps flag seems to have no effect when the NeedImports flag is set. And If you remove NeedImports, only a single package is reported, regardless of NeedDeps. It's as if the flag has no effect at all.
I would expect the following behaviors:
Imports=true, deps=true: import graph fully populated according to mode bits
imports=true, deps=false: import map is populated to depth 1; dependencies may be stubs.
imports=false: import map is nil. Deps flag has no effect.
The text was updated successfully, but these errors were encountered:
gopherbot
added
the
Tools
This label describes issues relating to any tools in the x/tools repository.
label
Nov 7, 2022
Package is both the "cooked" result data type of a Load
call, and the "raw" JSON schema used by DriverResponse.
This change documents the fields that are part of the
protocol, and ensures that the others are omitted from
the JSON encoding. (They are populated by the post-
processing done by 'refine', if the appropriate Need
bits are set.)
Also
- document that there are a number of open bugs
in places where it may be likely to help,
particularly Mode-related issues.
- document that Load returns new Packages,
using distinct symbol realms (types.Importers).
- document Overlays in slightly more detail.
Fixesgolang/go#67614Fixesgolang/go#61418Fixesgolang/go#67601Fixesgolang/go#43850
Updates golang/go#65816
Updates golang/go#58726
Updates golang/go#56677
Updates golang/go#48226
Updates golang/go#63517
Updates golang/go#56633
Change-Id: I2f5f2567baf61512042fc344fca56494f0f5e638
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588141
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
The documentation for the NeedDeps field is unclear. It says:
I think perhaps the idea might be more clearly expressed as:
but that isn't what actually happens. Observe:
In other words, the NeedDeps flag seems to have no effect when the NeedImports flag is set. And If you remove NeedImports, only a single package is reported, regardless of NeedDeps. It's as if the flag has no effect at all.
I would expect the following behaviors:
The text was updated successfully, but these errors were encountered: