You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By leveraging `depinject` and its Configuration API, you can efficiently handle dependencies in your blockchain application, ensuring a clean, modular, and well-organised codebase.
Example:
```go
package main
import (
"fmt"
"cosmossdk.io/depinject"
)
typeAnotherIntint
funcmain() {
var (
x int
y AnotherInt
)
fmt.Printf("Before (%v, %v)\n", x, y)
depinject.Inject(
depinject.Provide(
func() int { return1 },
func() AnotherInt { returnAnotherInt(2) },
),
&x,
&y,
)
fmt.Printf("After (%v, %v)\n", x, y)
}
```
If you execute the code in example, depinject.Inject will return an error Failed registering providers because of: function must be exported: main.main.func1.
I don't know the reason of why this isn't authorized any more, but now this example should actually looks like that :
Closecosmos#17743
Since cosmos#12797, it's no longer possible to use non-exported functions as
providers. The README used to contain examples with function literals as
provider, so this change replaces them with exported functions.
An additional change updates the `BindInterface` arguments, which wasn't
working on my side when running this code in go module called "duck".
Summary
In
depinject/README.md
, all code examples use function literals as providers, but this is not authorized any more.cosmos-sdk/depinject/README.md
Lines 33 to 65 in 36a9330
If you execute the code in example,
depinject.Inject
will return an errorFailed registering providers because of: function must be exported: main.main.func1
.I don't know the reason of why this isn't authorized any more, but now this example should actually looks like that :
The text was updated successfully, but these errors were encountered: