mirror of
https://github.com/golang/go
synced 2024-11-18 20:14:43 -07:00
go/packages: add some documentation for extractPackage
Change-Id: I68d4824157d389c0f08e871eec2b594f52717bae Reviewed-on: https://go-review.googlesource.com/c/tools/+/173478 Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
15bbd99efc
commit
bb3b3ca95a
@ -105,6 +105,10 @@ func extractImports(filename string, contents []byte) ([]string, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// extractPackage attempts to extract a package defined in an overlay.
|
||||
//
|
||||
// If the package has errors and has no Name, GoFiles, or Imports,
|
||||
// then it's possible that it doesn't yet exist on disk.
|
||||
func extractPackage(pkg *Package, filename string, contents []byte) bool {
|
||||
// TODO(rstambler): Check the message of the actual error?
|
||||
// It differs between $GOPATH and module mode.
|
||||
@ -124,10 +128,11 @@ func extractPackage(pkg *Package, filename string, contents []byte) bool {
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
// TODO(rstambler): This doesn't work for main packages.
|
||||
if filepath.Base(pkg.PkgPath) != f.Name.Name {
|
||||
return false
|
||||
}
|
||||
pkg.Name = f.Name.Name
|
||||
pkg.Errors = []Error{}
|
||||
pkg.Errors = nil
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user