Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc committed Sep 24, 2021
1 parent 4853a24 commit df6fa62
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (c *container) addNode(constructor *ProviderDescriptor, scope Scope, noLog
c.logf("Registering scope provider: %s", constructor.Location.String())
}
node := &scopeDepProvider{
ctr: constructor,
provider: constructor,
calledForScope: map[Scope]bool{},
valueMap: map[Scope][]reflect.Value{},
}
Expand Down
9 changes: 9 additions & 0 deletions container/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@ require (
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/fogleman/gg v1.3.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
10 changes: 5 additions & 5 deletions container/scope_dep.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

type scopeDepProvider struct {
provider *ProviderDescriptor
provider *ProviderDescriptor
calledForScope map[Scope]bool
valueMap map[Scope][]reflect.Value
}
Expand All @@ -18,20 +18,20 @@ type scopeDepResolver struct {
}

func (s scopeDepResolver) describeLocation() string {
return s.node.ctr.Location.String()
return s.node.provider.Location.String()
}

func (s scopeDepResolver) resolve(ctr *container, scope Scope, caller Location) (reflect.Value, error) {
// Log
ctr.logf("Providing %v from %s to %s", s.typ, s.node.ctr.Location, caller.Name())
ctr.logf("Providing %v from %s to %s", s.typ, s.node.provider.Location, caller.Name())

// Resolve
if val, ok := s.valueMap[scope]; ok {
return val, nil
}

if !s.node.calledForScope[scope] {
values, err := ctr.call(s.node.ctr, scope)
values, err := ctr.call(s.node.provider, scope)
if err != nil {
return reflect.Value{}, err
}
Expand All @@ -46,5 +46,5 @@ func (s scopeDepResolver) resolve(ctr *container, scope Scope, caller Location)
}

func (s scopeDepResolver) addNode(p *simpleProvider, _ int, _ *container) error {
return duplicateDefinitionError(s.typ, p.provider.Location, s.node.ctr.Location.String())
return duplicateDefinitionError(s.typ, p.provider.Location, s.node.provider.Location.String())
}

0 comments on commit df6fa62

Please sign in to comment.