@@ -148,23 +148,21 @@ func findFileCreator(rootDir string) func(file string) (string, string, bool) {
148148 rootDir = defaultRootDir (rootDir )
149149 prefix := findModuleDirective (rootDir )
150150 files := listAllFiles (rootDir )
151- findWalk := func (file , prefix string ) (string , string , bool ) {
151+ findFsSearch := func (file string ) (string , string , bool ) {
152152 noPrefixName := stripPrefix (file , prefix )
153- f , found := hasFile (files , noPrefixName )
153+ fPath := hasFile (files , noPrefixName )
154154
155- return path .NormalizeForOS (f ), noPrefixName , found
155+ return path .NormalizeForOS (fPath ), noPrefixName , fPath != ""
156156 }
157157
158158 return func (fileName string ) (string , string , bool ) {
159- if path , name , found := findWalk (fileName , prefix ); found {
159+ if path , name , found := findFsSearch (fileName ); found {
160160 return path , name , found
161161 }
162162
163- if path , name , found := findBuildImport (fileName ); found {
164- return path , name , found
165- }
166-
167- return "" , "" , false
163+ // when file is not find searching file system, search will fallback to
164+ // searching using build.Import, which can be slower on some systems (windows)
165+ return findBuildImport (fileName )
168166 }
169167}
170168
@@ -207,20 +205,22 @@ func listAllFiles(rootDir string) []fileInfo {
207205 return files
208206}
209207
210- func hasFile (files []fileInfo , search string ) ( string , bool ) {
208+ func hasFile (files []fileInfo , search string ) string {
211209 var result string
212210
213211 for _ , f := range files {
214212 if strings .HasSuffix (f .name , search ) {
215213 if result != "" {
216- return "" , false
214+ // when multiple files are found with same suffix
215+ // assume file is not found (fallback mechanism will be used)
216+ return ""
217217 }
218218
219219 result = f .path
220220 }
221221 }
222222
223- return result , result != ""
223+ return result
224224}
225225
226226func findAnnotations (source []byte ) ([]extent , error ) {
0 commit comments