[hz] router register occur "the router(%s) has been registered"
Describe the bug
生成http接口代码时,增加路由注册,会判断是否重复存在,此处判断逻辑有点问题,会出现误判断导致代码生成失败,如:"strategy.Register(r)"和"appstrategy.Register(r)"出现冲突
To Reproduce
Steps to reproduce the behavior:
代码位置
https://github.com/cloudwego/hertz/tree/develop/cmd/hz/generator/router.go
if !bytes.Contains(file, []byte(register.DepPkg)) {
file, err = util.AddImport(registerPath, register.DepPkgAlias, register.DepPkg)
if err != nil {
return err
}
insertReg := register.DepPkgAlias + ".Register(r)\n"
if bytes.Contains(file, []byte(insertReg)) {
return fmt.Errorf("the router(%s) has been registered", insertReg)
}
...
Expected behavior strategy.Register(r)"和"appstrategy.Register(r) 可正常共存
Screenshots
Hertz version: v0.9.5
Environment:
Additional context
This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.
ok, I will fix it later when I have time.
Closed by #1403