From 8a4ac7c7009d7155dfa1429a3a884ec66ea5e68a Mon Sep 17 00:00:00 2001 From: akutz Date: Sun, 20 Mar 2016 19:10:41 -0500 Subject: [PATCH] Fix for gotype bug against tests This patch fixes the issue described at https://github.com/alecthomas/gometalinter/issues/91 and implements the workaround described by https://github.com/alecthomas/gometalinter/issues/91#issuecomment-199061426. Essentially `go test -i PKG_PATH` is executed against any path prior to `gotype` being executed against that same path when the `gometalinter` flag `-tests` is used. This ensures that the test dependencies are installed as go packages, enabling `gotype` to resolve the imports. --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index f38bdcdd..f394c0e3 100644 --- a/main.go +++ b/main.go @@ -606,6 +606,13 @@ func executeLinter(state *linterState) error { if err != nil { return err } + if state.Name == "gotype" && state.vars["tests"] == "-t" { + debug("executing 'go test -i %s'", state.path) + err := exec.Command("go", "test", "-i").Run() + if err != nil { + return err + } + } debug("executing %s %q", exe, args) buf := bytes.NewBuffer(nil) cmd := exec.Command(exe, args...)