go/packages: minor fixes
This is fixes for review comments made on cl/128120 Change-Id: Ie6382d6ec91db2bbdece564a83ae028be4e2e269 Reviewed-on: https://go-review.googlesource.com/129000 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
69b93a3d4a
commit
7883bde2a5
|
@ -142,27 +142,27 @@ type Config struct {
|
||||||
TypeChecker types.Config
|
TypeChecker types.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// driver is the type for functions that return the package structure as
|
// driver is the type for functions that query the build system for the
|
||||||
// provided by a build system for the packages named by the given patterns.
|
// packages named by the patterns.
|
||||||
type driver func(cfg *Config, patterns ...string) (*driverResponse, error)
|
type driver func(cfg *Config, patterns ...string) (*driverResponse, error)
|
||||||
|
|
||||||
// driverResponse contains the results for a driver query.
|
// driverResponse contains the results for a driver query.
|
||||||
type driverResponse struct {
|
type driverResponse struct {
|
||||||
// Roots is the set of package IDs that make up the root packages.
|
// Roots is the set of package IDs that make up the root packages.
|
||||||
// We have to encode this separately because when we encode a single package
|
// We have to encode this separately because when we encode a single package
|
||||||
// we cannot know if it is one of the roots, that requires knowledge of the
|
// we cannot know if it is one of the roots as that requires knowledge of the
|
||||||
// graph it is part of.
|
// graph it is part of.
|
||||||
Roots []string `json:",omitempty"`
|
Roots []string `json:",omitempty"`
|
||||||
|
|
||||||
// Packages is the full set of packages in the graph.
|
// Packages is the full set of packages in the graph.
|
||||||
// The packages are not connected into a graph, the Imports if populated will be
|
// The packages are not connected into a graph.
|
||||||
// stubs that only have their ID set.
|
// The Imports if populated will be stubs that only have their ID set.
|
||||||
// It will be connected and then type and syntax information added in a later
|
// Imports will be connected and then type and syntax information added in a
|
||||||
// pass (see refine).
|
// later pass (see refine).
|
||||||
Packages []*Package
|
Packages []*Package
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load and returns the Go packages named by the given patterns.
|
// Load loads and returns the Go packages named by the given patterns.
|
||||||
//
|
//
|
||||||
// Config specifies loading options;
|
// Config specifies loading options;
|
||||||
// nil behaves the same as an empty Config.
|
// nil behaves the same as an empty Config.
|
||||||
|
@ -341,7 +341,7 @@ func (p *Package) UnmarshalJSON(b []byte) error {
|
||||||
OtherFiles: flat.OtherFiles,
|
OtherFiles: flat.OtherFiles,
|
||||||
ExportFile: flat.ExportFile,
|
ExportFile: flat.ExportFile,
|
||||||
}
|
}
|
||||||
if len(flat.Errors) >= 0 {
|
if len(flat.Errors) > 0 {
|
||||||
p.Errors = make([]error, len(flat.Errors))
|
p.Errors = make([]error, len(flat.Errors))
|
||||||
for i, err := range flat.Errors {
|
for i, err := range flat.Errors {
|
||||||
p.Errors[i] = err
|
p.Errors[i] = err
|
||||||
|
@ -499,7 +499,6 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ld.Mode < LoadImports {
|
if ld.Mode < LoadImports {
|
||||||
//TODO: we are throwing away correct information, is that the right thing to do?
|
|
||||||
//we do this to drop the stub import packages that we are not even going to try to resolve
|
//we do this to drop the stub import packages that we are not even going to try to resolve
|
||||||
for _, lpkg := range initial {
|
for _, lpkg := range initial {
|
||||||
lpkg.Imports = nil
|
lpkg.Imports = nil
|
||||||
|
|
Loading…
Reference in New Issue