aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/tools/go/packages/external.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/tools/go/packages/external.go')
-rw-r--r--vendor/golang.org/x/tools/go/packages/external.go39
1 files changed, 25 insertions, 14 deletions
diff --git a/vendor/golang.org/x/tools/go/packages/external.go b/vendor/golang.org/x/tools/go/packages/external.go
index 39e5ed99..22ff769e 100644
--- a/vendor/golang.org/x/tools/go/packages/external.go
+++ b/vendor/golang.org/x/tools/go/packages/external.go
@@ -16,7 +16,17 @@ import (
"strings"
)
-// findExternalTool returns the file path of a tool that supplies supplies
+// Driver
+type driverRequest struct {
+ Command string `json:"command"`
+ Mode LoadMode `json:"mode"`
+ Env []string `json:"env"`
+ BuildFlags []string `json:"build_flags"`
+ Tests bool `json:"tests"`
+ Overlay map[string][]byte `json:"overlay"`
+}
+
+// findExternalDriver returns the file path of a tool that supplies
// the build system package structure, or "" if not found."
// If GOPACKAGESDRIVER is set in the environment findExternalTool returns its
// value, otherwise it searches for a binary named gopackagesdriver on the PATH.
@@ -39,21 +49,22 @@ func findExternalDriver(cfg *Config) driver {
}
}
return func(cfg *Config, words ...string) (*driverResponse, error) {
- buf := new(bytes.Buffer)
- fullargs := []string{
- "list",
- fmt.Sprintf("-test=%t", cfg.Tests),
- fmt.Sprintf("-export=%t", usesExportData(cfg)),
- fmt.Sprintf("-deps=%t", cfg.Mode >= LoadImports),
- }
- for _, f := range cfg.Flags {
- fullargs = append(fullargs, fmt.Sprintf("-flags=%v", f))
+ req, err := json.Marshal(driverRequest{
+ Mode: cfg.Mode,
+ Env: cfg.Env,
+ BuildFlags: cfg.BuildFlags,
+ Tests: cfg.Tests,
+ Overlay: cfg.Overlay,
+ })
+ if err != nil {
+ return nil, fmt.Errorf("failed to encode message to driver tool: %v", err)
}
- fullargs = append(fullargs, "--")
- fullargs = append(fullargs, words...)
- cmd := exec.CommandContext(cfg.Context, tool, fullargs...)
- cmd.Env = cfg.Env
+
+ buf := new(bytes.Buffer)
+ cmd := exec.CommandContext(cfg.Context, tool, words...)
cmd.Dir = cfg.Dir
+ cmd.Env = cfg.Env
+ cmd.Stdin = bytes.NewReader(req)
cmd.Stdout = buf
cmd.Stderr = new(bytes.Buffer)
if err := cmd.Run(); err != nil {