diff --git a/README.md b/README.md index 65c5340..64aa549 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/api.go b/api.go index bbc18a3..565a4a4 100644 --- a/api.go +++ b/api.go @@ -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) } @@ -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...) } @@ -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. diff --git a/bind.go b/bind.go index 09a8c9b..559061d 100644 --- a/bind.go +++ b/bind.go @@ -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 } diff --git a/bind_test.go b/bind_test.go index 8acfbdd..ac894c8 100644 --- a/bind_test.go +++ b/bind_test.go @@ -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 }), diff --git a/characterize.go b/characterize.go index a30151b..15ac08b 100644 --- a/characterize.go +++ b/characterize.go @@ -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 @@ -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)) }, }, diff --git a/characterize_test.go b/characterize_test.go index ac36442..6acc94b 100644 --- a/characterize_test.go +++ b/characterize_test.go @@ -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 } diff --git a/condense.go b/condense.go index 1c48692..1066b80 100644 --- a/condense.go +++ b/condense.go @@ -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, diff --git a/doc.go b/doc.go index b3ed4d7..c0cd9c0 100644 --- a/doc.go +++ b/doc.go @@ -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 @@ -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). @@ -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", @@ -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. diff --git a/example_memoize_test.go b/example_memoize_test.go index f913263..66ce2b7 100644 --- a/example_memoize_test.go +++ b/example_memoize_test.go @@ -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 diff --git a/filler.go b/filler.go index dbf9760..aba099a 100644 --- a/filler.go +++ b/filler.go @@ -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. diff --git a/filler_api.go b/filler_api.go index 3e79c62..5b7bf87 100644 --- a/filler_api.go +++ b/filler_api.go @@ -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) { @@ -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 diff --git a/flows.go b/flows.go index 32728ed..8b1c0fd 100644 --- a/flows.go +++ b/flows.go @@ -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: @@ -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() diff --git a/flows_test.go b/flows_test.go index 97f61f4..ab40255 100644 --- a/flows_test.go +++ b/flows_test.go @@ -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") } diff --git a/generate.go b/generate.go index 4e87fa2..5114de1 100644 --- a/generate.go +++ b/generate.go @@ -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 } @@ -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 } @@ -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) @@ -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 } diff --git a/include.go b/include.go index c4de7b4..fd7c410 100644 --- a/include.go +++ b/include.go @@ -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") @@ -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 } @@ -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)) diff --git a/overrides_error.go b/overrides_error.go index 84858c6..fa49a50 100644 --- a/overrides_error.go +++ b/overrides_error.go @@ -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 { diff --git a/reflective.go b/reflective.go index 69233ee..527fcca 100644 --- a/reflective.go +++ b/reflective.go @@ -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) @@ -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. @@ -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 diff --git a/reorder.go b/reorder.go index 5efba33..cb7b480 100644 --- a/reorder.go +++ b/reorder.go @@ -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. // @@ -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) } @@ -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 { @@ -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) } @@ -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) diff --git a/stringer_generated.go b/stringer_generated.go index 56b8848..aa06a22 100644 --- a/stringer_generated.go +++ b/stringer_generated.go @@ -58,7 +58,7 @@ func _() { _ = x[returnParams-0] _ = x[outputParams-1] _ = x[inputParams-2] - _ = x[receviedParams-3] + _ = x[receivedParams-3] _ = x[bypassParams-4] _ = x[lastFlowType-5] } diff --git a/types.go b/types.go index 36d98ff..7eb6d9a 100644 --- a/types.go +++ b/types.go @@ -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 @@ -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 // diff --git a/utils.go b/utils.go index ad0cea4..bb0c44e 100644 --- a/utils.go +++ b/utils.go @@ -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)