From 176c208e84d0191d463e1c14eeb52e31ca8b2f69 Mon Sep 17 00:00:00 2001 From: Zhongpeng Lin Date: Fri, 31 May 2019 22:28:45 -0700 Subject: [PATCH] Allow mockgen to execute from outside go modules --- mockgen/parse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mockgen/parse.go b/mockgen/parse.go index 9c5475e9..d25e3ce5 100644 --- a/mockgen/parse.go +++ b/mockgen/parse.go @@ -47,7 +47,7 @@ func parseFile(source string) (*model.Package, error) { return nil, fmt.Errorf("failed getting source directory: %v", err) } - cfg := &packages.Config{Mode: packages.LoadSyntax, Tests: true} + cfg := &packages.Config{Mode: packages.LoadFiles, Tests: true, Dir: srcDir} pkgs, err := packages.Load(cfg, "file="+source) if err != nil { return nil, err