-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: asynchronous loading of root module parts (#219)
* rootmodules: Surface whole RootModule candidates instead of paths * refactor: asynchronous loading of root module parts * make test data accessible for linux & windows too * address PR feedback
- Loading branch information
1 parent
bf57c3e
commit c41d592
Showing
68 changed files
with
995 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package rootmodule | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func findFile(paths []string) (File, error) { | ||
var lf File | ||
var err error | ||
|
||
for _, path := range paths { | ||
lf, err = newFile(path) | ||
if err == nil { | ||
return lf, nil | ||
} | ||
if !os.IsNotExist(err) { | ||
return nil, err | ||
} | ||
} | ||
|
||
return nil, err | ||
} | ||
|
||
type file struct { | ||
path string | ||
} | ||
|
||
func (f *file) Path() string { | ||
return f.path | ||
} | ||
|
||
func newFile(path string) (File, error) { | ||
fi, err := os.Stat(path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if fi.IsDir() { | ||
return nil, fmt.Errorf("expected %s to be a file, not a dir", path) | ||
} | ||
|
||
return &file{path: path}, nil | ||
} |
Oops, something went wrong.