We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Wire doesn't support generics when I pass a generic function in wire.NewSet
Pass generic function in wire.NewSet, like this:
wire.NewSet( db.New[config.DBConfigDefault, config.DBInstanceDefault], ent.New, redis.New, discovery.New, casbin.New, grpc.New, uid.New, )
or
var ProviderSet = wire.NewSet( GetApp, GetHTTP, GetGRPC, GetDB[DBKeyDefault, DBConfigDefault], GetRedis, GetTrace, GetDiscovery, GetServices, GetJWT, GetCasbin, )
Then, wire reports an error like this:
$ wire wire: /example/internal/config/config.go:16:2: unknown pattern wire: /example/internal/app/app.go:27:3: unknown pattern wire: /example/internal/config/config.go:16:2: unknown pattern wire: /example/internal/app/app.go:27:3: unknown pattern wire: /example/internal/app/app.go:27:3: unknown pattern wire: /example/internal/command: generate failed wire: at least one generate failure
can generate code correctly
github.com/google/wire v0.5.1-0.20220620021424-0675cdc9191c
Here is my code:
func GetDB[K DBKeyGetter, V DBConfigGroup]() (V, error) { c, err := getEntry(config.DB) if err != nil { return V{}, err } var k K return V(c[k.GetName()]), nil }
func New[C config.DBConfigGroup, D config.DBInstanceGroup](conf C, logger *slog.Logger) (db D, cleanup func(), err error) { // code }
The text was updated successfully, but these errors were encountered:
You can use workaround like this
wire.NewSet( newDb, ent.New, redis.New, discovery.New, casbin.New, grpc.New, uid.New, ) func newDb(conf config.DBConfigDefault, logger *slog.Logger) (db config.DBInstanceDefault, cleanup func(), err error) { return db.New[config.DBConfigDefault, config.DBInstanceDefault] }
Sorry, something went wrong.
No branches or pull requests
Describe the bug
Wire doesn't support generics when I pass a generic function in wire.NewSet
To Reproduce
Pass generic function in wire.NewSet, like this:
or
Then, wire reports an error like this:
Expected behavior
can generate code correctly
Version
github.com/google/wire v0.5.1-0.20220620021424-0675cdc9191c
Additional context
Here is my code:
The text was updated successfully, but these errors were encountered: