-
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
- Loading branch information
1 parent
499d12d
commit 9a81f4c
Showing
29 changed files
with
750 additions
and
336 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.