go/packages: add doc for the current state of overlays

Change-Id: Iba4ea587d7a14a1b930df122c925d1bc2f39eda8
Reviewed-on: https://go-review.googlesource.com/c/153678
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
Michael Matloob 2018-12-11 17:08:25 -05:00
parent 2b6afc6596
commit 59cd96f77e
2 changed files with 9 additions and 19 deletions

View File

@ -180,22 +180,13 @@ Instead, ssadump no longer requests the runtime package,
but seeks it among the dependencies of the user-specified packages, but seeks it among the dependencies of the user-specified packages,
and emits an error if it is not found. and emits an error if it is not found.
Overlays: the ParseFile hook in the API permits clients to vary the way Overlays: The Overlay field in the Config allows providing alternate contents
in which ASTs are obtained from filenames; the default implementation is for Go source files, by providing a mapping from file path to contents.
based on parser.ParseFile. This features enables editor-integrated tools go/packages will pull in new imports added in overlay files when go/packages
that analyze the contents of modified but unsaved buffers: rather than is run in LoadImports mode or greater.
read from the file system, a tool can read from an archive of modified Overlay support for the go list driver isn't complete yet: if the file doesn't
buffers provided by the editor. exist on disk, it will only be recognized in an overlay if it is a non-test file
This approach has its limits. Because package metadata is obtained by and the package would be reported even without the overlay.
fork/execing an external query command for each build system, we can
fake only the file contents seen by the parser, type-checker, and
application, but not by the metadata query, so, for example:
- additional imports in the fake file will not be described by the
metadata, so the type checker will fail to load imports that create
new dependencies.
- in TypeCheck mode, because export data is produced by the query
command, it will not reflect the fake file contents.
- this mechanism cannot add files to a package without first saving them.
Questions & Tasks Questions & Tasks

View File

@ -125,9 +125,8 @@ type Config struct {
// If the file with the given path already exists, the parser will use the // If the file with the given path already exists, the parser will use the
// alternative file contents provided by the map. // alternative file contents provided by the map.
// //
// The Package.Imports map may not include packages that are imported only // Overlays provide incomplete support for when a given file doesn't
// by the alternative file contents provided by Overlay. This may cause // already exist on disk. See the package doc above for more details.
// type-checking to fail.
Overlay map[string][]byte Overlay map[string][]byte
} }