diff options
author | Michael Matloob <matloob@golang.org> | 2020-08-11 12:57:01 -0400 |
---|---|---|
committer | Michael Matloob <matloob@golang.org> | 2020-10-06 19:00:07 +0000 |
commit | ab2a5b48665eed6d670d719cdef5335bc3602359 (patch) | |
tree | 8a897d0a57a5ff5b12e4cb52e3be610c9eb1e93e /src/cmd/go/internal/cfg/cfg.go | |
parent | f8d80977b784fd4879963e61dc9fca1fc9bf2193 (diff) | |
download | go-ab2a5b48665eed6d670d719cdef5335bc3602359.tar.gz go-ab2a5b48665eed6d670d719cdef5335bc3602359.zip |
cmd/go: add basic support for overlays
This CL adds basic support for listing packages with overlays.
The new cmd/go/internal/fs package adds an abstraction for communicating
with the file system that will open files according to their overlaid paths,
and provides functions to override those in the build context to open
overlaid files. There is also some support for executing builds on packages
with overlays. In cmd/go/internal/work.(*Builder).build, paths are mapped
to their overlaid paths before they are given as arguments to tools.
For #39958
Change-Id: I5ec0eb9ebbca303e2f1e7dbe22ec32613bc1fd17
Reviewed-on: https://go-review.googlesource.com/c/go/+/253747
Trust: Michael Matloob <matloob@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/cfg/cfg.go')
-rw-r--r-- | src/cmd/go/internal/cfg/cfg.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go index ebbaf04115..9169c12d8f 100644 --- a/src/cmd/go/internal/cfg/cfg.go +++ b/src/cmd/go/internal/cfg/cfg.go @@ -11,6 +11,7 @@ import ( "fmt" "go/build" "internal/cfg" + "io" "io/ioutil" "os" "path/filepath" @@ -18,6 +19,8 @@ import ( "strings" "sync" + "cmd/go/internal/fsys" + "cmd/internal/objabi" ) @@ -104,6 +107,15 @@ func defaultContext() build.Context { // Nothing to do here. } + ctxt.OpenFile = func(path string) (io.ReadCloser, error) { + return fsys.Open(path) + } + ctxt.ReadDir = fsys.ReadDir + ctxt.IsDir = func(path string) bool { + isDir, err := fsys.IsDir(path) + return err == nil && isDir + } + return ctxt } |