wire: change call sites to allow multiple errors (google/go-cloud#118)

Updated the call sites to allow multiple errors to be returned from
the package. Load is now permitted to return partial success.

Updates google/go-cloud#5
This commit is contained in:
Ross Light
2018-06-25 10:30:34 -07:00
parent 45a535a0bd
commit f7658c8a13
4 changed files with 79 additions and 67 deletions

View File

@@ -144,8 +144,9 @@ type Value struct {
}
// Load finds all the provider sets in the given packages, as well as
// the provider sets' transitive dependencies.
func Load(bctx *build.Context, wd string, pkgs []string) (*Info, error) {
// the provider sets' transitive dependencies. It may return both an error
// and Info.
func Load(bctx *build.Context, wd string, pkgs []string) (*Info, []error) {
// TODO(light): Stop errors from printing to stderr.
conf := &loader.Config{
Build: bctx,
@@ -157,7 +158,7 @@ func Load(bctx *build.Context, wd string, pkgs []string) (*Info, error) {
}
prog, err := conf.Load()
if err != nil {
return nil, fmt.Errorf("load: %v", err)
return nil, []error{fmt.Errorf("load: %v", err)}
}
info := &Info{
Fset: prog.Fset,