@@ -129,7 +129,11 @@ func runInDir(program []byte, dir string) (*model.Package, error) {
129
129
if err := cmd .Run (); err != nil {
130
130
return nil , err
131
131
}
132
- return run (filepath .Join (tmpDir , progBinary ))
132
+ p , err := run (filepath .Join (tmpDir , progBinary ))
133
+ if err == nil {
134
+ log .Printf ("Successfully reflected in directory: %v\n " , err )
135
+ }
136
+ return p , err
133
137
}
134
138
135
139
// reflectMode generates mocks via reflection on an interface.
@@ -152,6 +156,11 @@ func reflectMode(importPath string, symbols []string) (*model.Package, error) {
152
156
153
157
wd , _ := os .Getwd ()
154
158
159
+ // Try to run it in the current working directory.
160
+ if p , err := runInDir (program , wd ); err == nil {
161
+ return p , nil
162
+ }
163
+
155
164
// Try to run the program in the same directory as the input package.
156
165
if p , err := build .Import (importPath , wd , build .FindOnly ); err == nil {
157
166
dir := p .Dir
@@ -160,11 +169,7 @@ func reflectMode(importPath string, symbols []string) (*model.Package, error) {
160
169
}
161
170
}
162
171
163
- // Since that didn't work, try to run it in the current working directory.
164
- if p , err := runInDir (program , wd ); err == nil {
165
- return p , nil
166
- }
167
- // Since that didn't work, try to run it in a standard temp directory.
172
+ // Try to run it in a standard temp directory.
168
173
return runInDir (program , "" )
169
174
}
170
175
0 commit comments