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
When using wire to generate code, the console prompts an error message
$ wire wire: E:\product-channel-beauty-order-service\internal\cmd\main.go:69:35: not enough arguments in call to misc.GetConfig wire: generate failed
Tried to search for a solution but did not find a way, I hope you can help to investigate
Execute the wire command in the cmd directory to reproduce
wire
cmd
Personally think that the problem is caused by the generic type of [T any]go
[T any]
go version: 1.20 wire version: v0.5.0
1.20
v0.5.0
├─cmd │ main.go │ wire.go
... func main() { flag.Parse() logger := log.With(log.NewStdLogger(os.Stdout), "ts", func(context.Context) interface{} { z := time.FixedZone("GMT", 8) return time.Now().In(z).Format("2006-01-02 15:04:05") }, "caller", log.DefaultCaller, "host", Host, "trace.id", tracing.TraceID(), "span.id", tracing.SpanID(), ) abs, err := filepath.Abs(flagconf) if err != nil { panic(err) } var bc internal.Bootstrap if err := misc.GetConfig(abs, &bc); err != nil { panic(err) } app, cleanup, err := wireApp(&bc, logger) if err != nil { panic(err) } defer cleanup() // start and wait for stop signal if err := app.Run(); err != nil { panic(err) } } ...
... func wireApp(*internal.Bootstrap, log.Logger) (*kratos.App, func(), error) { panic(wire.Build(data.DataProviderSets, server.ServerProviderSets, depends.DependsProviderSets, service.ServiceProviderSets, newApp)) } ...
GetConfig
package misc import ( "github.com/go-kratos/kratos/v2/log" "github.com/pkg/errors" "gopkg.in/yaml.v3" "os" ) func GetConfig[T any](path string, t *T) error { file, err := os.ReadFile(path) if err != nil { log.Errorf("read config failed:%v", err) return err } err = yaml.Unmarshal(file, t) if err == nil { return nil } err = JSON.Unmarshal(file, t) if err == nil { return nil } return errors.New("unrecognized file") }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
When using wire to generate code, the console prompts an error message
Tried to search for a solution but did not find a way, I hope you can help to investigate
To Reproduce
Execute the
wire
command in thecmd
directory to reproduceExpected behavior
Personally think that the problem is caused by the generic type of
[T any]
goVersion
go version:
1.20
wire version:
v0.5.0
Additional context
GetConfig
The text was updated successfully, but these errors were encountered: