Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some typos #60

Merged
merged 1 commit into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ other collections.
## Debugging injector chains

If you chain successfully binds but does not do what you expect, add
something into your chain that recevies the `nject.Debugging` type:
something into your chain that receives the `nject.Debugging` type:

func(d *nject.Debugging) {
fmt.Println("Injectors included\n", d.Included)
Expand Down
6 changes: 3 additions & 3 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Provider interface {
// the net consumes and returns.
//
// Providers that return TerminalError are a special case and count as
// producting error.
// producing error.
UpFlows() (consume []reflect.Type, produce []reflect.Type)
}

Expand All @@ -58,7 +58,7 @@ type Provider interface {
// with Required. Providers that produce no output are always run.
//
// Previsously created *Collection objects are considered providers along
// with *Provider, named functions, anoymous functions, and literal values.
// with *Provider, named functions, anonymous functions, and literal values.
func Sequence(name string, providers ...interface{}) *Collection {
return newCollection(name, providers...)
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func NotCacheable(fn interface{}) Provider {
// Memoized providers will remember every combination of imputs they
// have ever seen. This can exhaust all memory.
//
// By default, Memozied providers are Cachable, but that doesn't force
// By default, Memozied providers are Cacheable, but that doesn't force
// the provider into the STATIC set where it runs infrequently.
// Combine Memoize with MustCache to make sure that Memoize is actually
// in the STATIC set where it probably won't exhaust all memory.
Expand Down
2 changes: 1 addition & 1 deletion bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func doBind(sc *Collection, originalInvokeF *provider, originalInitF *provider,
return err
}

inMap, err := generateInputMapper(invokeF, 0, receviedParams, invokeF.upRmap, upVmap, "invoke results")
inMap, err := generateInputMapper(invokeF, 0, receivedParams, invokeF.upRmap, upVmap, "invoke results")
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ func TestTerminalErrorMultiBinding(t *testing.T) {
}

var ternbbte = Sequence("ternbbte",
// this func is required because it recevies from the final func
// this func is required because it receives from the final func
Provide("WRAPPER", func(func() (s2, error), s1) {}),
Provide("TERMINAL", func() TerminalError { return nil }),
Provide("FINAL", func() (s2, error) { return "", nil }),
Expand Down
6 changes: 3 additions & 3 deletions characterize.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ var invokeRegistry = typeRegistry{
a.fm.class = invokeFunc
if _, ok := a.fm.fn.(ReflectiveInvoker); ok {
a.fm.flows[outputParams] = toTypeCodes(typesIn(a.t))
a.fm.flows[receviedParams] = toTypeCodes(typesOut(a.t))
a.fm.flows[receivedParams] = toTypeCodes(typesOut(a.t))
} else {
a.fm.flows[outputParams] = toTypeCodes(typesIn(a.t.Elem()))
a.fm.flows[receviedParams] = toTypeCodes(typesOut(a.t.Elem()))
a.fm.flows[receivedParams] = toTypeCodes(typesOut(a.t.Elem()))
}
a.fm.required = true
a.fm.isSynthetic = true
Expand Down Expand Up @@ -517,7 +517,7 @@ var handlerRegistry = typeRegistry{
inner = a.t.In(0)
}
a.fm.flows[outputParams] = toTypeCodes(typesIn(inner))
a.fm.flows[receviedParams] = toTypeCodes(typesOut(inner))
a.fm.flows[receivedParams] = toTypeCodes(typesOut(inner))
},
},

Expand Down
2 changes: 1 addition & 1 deletion characterize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (flows flowMapType) output(f ...typeCode) flowMapType {
}

func (flows flowMapType) returned(f ...typeCode) flowMapType {
flows[receviedParams] = f
flows[receivedParams] = f
return flows
}

Expand Down
2 changes: 1 addition & 1 deletion condense.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (c *Collection) Condense(treatErrorAsTerminal bool) (Provider, error) {
}
debugFound = true

// collections don't have a convienent method for
// collections don't have a convenient method for
// prepending something to their contents so we'll
// build a replacement instead.
c = Sequence(name,
Expand Down
8 changes: 4 additions & 4 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Cached injectors

In injector that is annotated as Cacheable() may promoted to the STATIC set.
An injector that is annotated as MustCache() must be promoted to
the STATIC set: if it cannot be promoted then the colection is deemed invalid.
the STATIC set: if it cannot be promoted then the collection is deemed invalid.

An injector may not be promoted to the STATIC set if it takes as
input data that comes from a provider that is not in the STATIC or
Expand Down Expand Up @@ -190,7 +190,7 @@ downstream.
If a non-nil value is returned as the TerminalError from a fallible
injector in the STATIC set, the rest of the STATIC set will be skipped.
If there is an init function and it returns error, then the value returned
by the fallible injector will be returned via init fuction. Unlike
by the fallible injector will be returned via init function. Unlike
fallible injectors in the RUN set, the error output by a fallible injector
in the STATIC set is available downstream (but only in the RUN set -- nothing
else in the STATIC set will execute).
Expand Down Expand Up @@ -367,7 +367,7 @@ providers. Customization of the import chains happens in many places.

This is true for services, libraries, and tests.

For tests, a wrapper that includes the stanard chain makes it eaiser
For tests, a wrapper that includes the standard chain makes it easier
to write tests.

var CommonChain = nject.Sequence("common",
Expand Down Expand Up @@ -461,7 +461,7 @@ and used.

Self-cleaning

Recommened best practice is to have injectors shutdown the things they themselves start. They
Recommended best practice is to have injectors shutdown the things they themselves start. They
should do their own cleanup.

Inside tests, an injector can use t.Cleanup() for this.
Expand Down
2 changes: 1 addition & 1 deletion example_memoize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// as desired, also mark functions with MustCache.
// With the same inputs, cached answers
// are always used. The cache lookup examines the values passed, but does not
// do a deep insepection.
// do a deep inspection.
func ExampleMemoize() {
type aStruct struct {
ValueInStruct int
Expand Down
2 changes: 1 addition & 1 deletion filler.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ var reservedTags = map[string]struct{}{
// (created with PostActionByTag) may not uses these names:
//
// "whole" & "blob": indicate that an embedded struct should be filled as
// a blob rather thatn field-by-field.
// a blob rather than field-by-field.
//
// "field" & "fields": indicates that an embedded struct should be filled
// field-by-field. This is the default and the tag exists for clarity.
Expand Down
4 changes: 2 additions & 2 deletions filler_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func PostActionByTag(tagValue string, function interface{}, opts ...PostActionFu
// thin wrapper around a function. We'll select the closest
// match between the function input and the field and replace
// that type in the list of inputs with the struct being filled.
// The actuall Call() we will grab the field from the struct
// The actual Call() we will grab the field from the struct
// using it's index and use that to call the function.
options := makePostActionOption(function, opts)
return func(o *fillerOptions) {
Expand Down Expand Up @@ -181,7 +181,7 @@ func makePostActionOption(function interface{}, userOpts []PostActionFuncArg, ty

// WithFill overrides the default behaviors of PostActionByType, PostActionByName,
// and PostActionByTag with respect to the field being automatically filled.
// By default, if there is a post-action that that recevies a pointer to the
// By default, if there is a post-action that that receives a pointer to the
// field, then the field will not be filled from the injection chain.
//
// EXPERIMENTAL: this is currently considered experimental
Expand Down
4 changes: 2 additions & 2 deletions flows.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (fm provider) UpFlows() ([]reflect.Type, []reflect.Type) {
case unsetClassType:
// continue
default:
return fm.flows[receviedParams].Types(), fm.flows[returnParams].Types()
return fm.flows[receivedParams].Types(), fm.flows[returnParams].Types()
}
switch r := fm.fn.(type) {
case Reflective:
Expand Down Expand Up @@ -178,7 +178,7 @@ func effectiveReturns(fn reflectType) ([]reflect.Type, []reflect.Type) {
// be counted only by what it consumes.
//
// Providers that return TerminalError are a special case and count as
// producting error.
// producing error.
func (c Collection) UpFlows() ([]reflect.Type, []reflect.Type) {
return c.netFlows(func(fm *provider) ([]reflect.Type, []reflect.Type) {
return fm.UpFlows()
Expand Down
2 changes: 1 addition & 1 deletion flows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestFlows(t *testing.T) {
assert.Equal(t, toStrings(wantUpOut), flowToStrings(fm.flows[returnParams]), "char up out")
assert.Equal(t, toStrings(wantDownOut), flowToStrings(fm.flows[outputParams]), "char down out")
assert.Equal(t, toStrings(wantDownIn), flowToStrings(fm.flows[inputParams]), "char down in")
assert.Equal(t, toStrings(wantUpIn), flowToStrings(fm.flows[receviedParams]), "char up in")
assert.Equal(t, toStrings(wantUpIn), flowToStrings(fm.flows[receivedParams]), "char up in")

fCheck(p, "characterized")
}
Expand Down
12 changes: 6 additions & 6 deletions generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func generateWrappers(
}

case wrapperFunc:
inMap, err := generateInputMapper(fm, 1, inputParams, fm.downRmap, downVmap, "in(w)") // parmeters to the middleware handler
inMap, err := generateInputMapper(fm, 1, inputParams, fm.downRmap, downVmap, "in(w)") // parameters to the middleware handler
if err != nil {
return err
}
Expand All @@ -186,7 +186,7 @@ func generateWrappers(
if err != nil {
return err
}
retMap, err := generateInputMapper(fm, 0, receviedParams, fm.upRmap, upVmap, "ret(w)") // return values from inner()
retMap, err := generateInputMapper(fm, 0, receivedParams, fm.upRmap, upVmap, "ret(w)") // return values from inner()
if err != nil {
return err
}
Expand All @@ -199,12 +199,12 @@ func generateWrappers(
vCopy := v.Copy()
callCount := 0

rTypes := make([]reflect.Type, len(fm.flows[receviedParams]))
for i, tc := range fm.flows[receviedParams] {
rTypes := make([]reflect.Type, len(fm.flows[receivedParams]))
for i, tc := range fm.flows[receivedParams] {
rTypes[i] = tc.Type()
}

// for thread safty, this is not built outside WrapWrapper
// for thread safety, this is not built outside WrapWrapper
inner := func(i []reflect.Value) []reflect.Value {
if callCount > 0 {
copy(v, vCopy)
Expand Down Expand Up @@ -342,7 +342,7 @@ func generateWrappers(
if err != nil {
return err
}
zero, err := makeZero(fm, downVmap, fm.mustZeroIfRemainderSkipped, "need to fill in values set in skippped functions")
zero, err := makeZero(fm, downVmap, fm.mustZeroIfRemainderSkipped, "need to fill in values set in skipped functions")
if err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions include.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ func computeDependenciesAndInclusion(funcs []*provider, initF *provider) ([]*pro
}
}
}
debugf("lenth of without before: %d", len(without))
debugf("length of without before: %d", len(without))
// nolint:govet
err := validateChainMarkIncludeExclude(funcs, false)
debugf("lenth of without after: %d", len(without))
debugf("length of without after: %d", len(without))
for _, fm := range without {
if err == nil {
fm.d.excluded = fmt.Errorf("not required, not desired, not necessary")
Expand Down Expand Up @@ -359,11 +359,11 @@ func providesReturns(funcs []*provider, initF *provider) error {
debugf("\tskipping on upward path %s: %s", fm, fm.cannotInclude)
continue
}
err := requireParameters(fm, returns, receviedParams, returnParams, fm.upRmap, "expected return")
err := requireParameters(fm, returns, receivedParams, returnParams, fm.upRmap, "expected return")
if err != nil {
return err
}
provideParameters(fm, returns, returnParams, receviedParams, len(funcs)-i+2)
provideParameters(fm, returns, returnParams, receivedParams, len(funcs)-i+2)
}
return nil
}
Expand Down Expand Up @@ -465,7 +465,7 @@ func proposeEliminations(funcs []*provider) []*provider {
useLast bool
}{
{"down", []flowType{inputParams, bypassParams}, true},
{"up", []flowType{receviedParams}, false},
{"up", []flowType{receivedParams}, false},
} {
keep := make([]bool, len(funcs))
toKeep := make([]*provider, 0, len(funcs))
Expand Down
2 changes: 1 addition & 1 deletion overrides_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// does not expect to receive an error will cause the injection chain
// compilation to fail.
//
// A common mistake is to have an wrapper that accidently returns error. It
// A common mistake is to have an wrapper that accidentally returns error. It
// looks like this:
//
// func AutoCloseThing(inner func(someType), param anotherType) error {
Expand Down
6 changes: 3 additions & 3 deletions reflective.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// ReflectiveInvoker is an alternative provider interface that can be used
// for invoke and initialize functions. The key for those functions is that
// their implmentation is provided by Collection.Bind.
// their implementation is provided by Collection.Bind.
type ReflectiveInvoker interface {
ReflectiveArgs
Set(func([]reflect.Value) []reflect.Value)
Expand Down Expand Up @@ -113,7 +113,7 @@ func (r thinReflective) String() string {

// MakeReflectiveWrapper is a utility to create a ReflectiveWrapper
//
// The first argument, downIn, is the types that must be recevied in the down
// The first argument, downIn, is the types that must be received in the down
// chain and provided to function. This does not include the
// func([]reflec.Value) []reflect.Value that is actually used for the first
// argument.
Expand All @@ -123,7 +123,7 @@ func (r thinReflective) String() string {
// The third argument, downOut, is the types provided in the call to the inner
// function and thus are passed down the down chain.
//
// The forth agument, upIn, is the types returned by the call to the inner
// The forth argument, upIn, is the types returned by the call to the inner
// function and thus are received from the up chain.
//
// When function is called, the first argument will be a reflect.Value, of
Expand Down
10 changes: 5 additions & 5 deletions reorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func Reorder(fn interface{}) Provider {
// a pseudo node that represents that T has been provided.
//
// A provider that returns a type T on the up-chain, is after
// a pseudo node that represents that T has been recevied as
// a pseudo node that represents that T has been received as
// as a return value in the up-chain.
//

Expand Down Expand Up @@ -106,7 +106,7 @@ func reorder(funcs []*provider, initF *provider) ([]*provider, error) {
provideByNotRequire[t] = append(provideByNotRequire[t], i)
}
}
for _, t := range noNoType(fm.flows[receviedParams]) {
for _, t := range noNoType(fm.flows[receivedParams]) {
if !fm.d.hasFlow[returnParams](t) {
receviedNotReturned[t] = append(receviedNotReturned[t], i)
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func reorder(funcs []*provider, initF *provider) ([]*provider, error) {
continue
}
// if you return a T, you're not marked consumptionOptional, then you
// MUST be be after a provider that recevies a T as a returned value
// MUST be after a provider that receives a T as a returned value
if num, ok := upTypes[t]; ok {
aAfterB(!fm.consumptionOptional, i, num)
} else {
Expand All @@ -186,7 +186,7 @@ func reorder(funcs []*provider, initF *provider) ([]*provider, error) {
counter++
}
// if you return a T, then you SHOULD be be after all providers that
// recevie a T as a returned value
// receive a T as a returned value
for _, j := range receviedNotReturned[t] {
aAfterB(false, i, j)
}
Expand Down Expand Up @@ -374,7 +374,7 @@ func (x *topo) releaseProvider(i int, fm *provider) {
x.release(num, i)
}
}
for _, t := range noNoType(fm.flows[receviedParams]) {
for _, t := range noNoType(fm.flows[receivedParams]) {
if num, ok := x.upTypes[t]; ok {
debugln("\trelease up", t)
x.release(num, i)
Expand Down
2 changes: 1 addition & 1 deletion stringer_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Debugging struct {
NamesIncluded []string

// IncludeExclude is a list of all of the providers supplied to
// ceate the chain. Why each was included or not explained.
// create the chain. Why each was included or not explained.
// "INCLUDED ${groupName} ${className} ${providerNameShape} BECAUSE ${whyProviderWasInclude}"
// "EXCLUDED ${groupName} ${className} ${providerNameShape} BECAUSE ${whyProviderWasExcluded}"
IncludeExclude []string
Expand Down Expand Up @@ -97,10 +97,10 @@ const (
returnParams flowType = iota // returns
// going down
outputParams // outputs
// recevied from above
// received from above
inputParams // inputs
// received from below (callee returned)
receviedParams // recevied
receivedParams // received
// gathered from the end of the static chain and returned from init
bypassParams // bypass
//
Expand Down
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func Curry(originalFunction interface{}, pointerToCurriedFunction interface{}) (
}
curried := make([]reflect.Type, 0, curryCount) // injected inputs
alreadyCurried := make(map[reflect.Type]struct{}) // to prevent double-dipping
curryMap := make([]int, 0, curryCount) // maps postion from injected inputs to to original
curryMap := make([]int, 0, curryCount) // maps position from injected inputs to to original
passMap := make([]int, n.Type().Elem().NumIn()) // maps position from curried to original
for i := 0; i < o.Type().NumIn(); i++ {
t := o.Type().In(i)
Expand Down