Skip to content
New issue

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

Thrift files with different namespaces but the same ending cannot be used for hz update. #1028

Open
ozline opened this issue Dec 15, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@ozline
Copy link

ozline commented Dec 15, 2023

Describe the bug

There are currently two thrift files, with the namespaces respectively:

namespace go admin.b

namespace go b

When using the "hz update" command to update at this time, an error will occur.

plugin thriftgo_gen_hertz returns error: exit status 2, cause:
[WARN] stdout:

[WARN] stderr:
[ERROR]/Users/ozlinex/go/pkg/mod/github.com/cloudwego/hertz/cmd/[email protected]/thrift/plugin.go:162: generate package failed: update register for biz/router/technician/register.go failed, err: the router(technician.Register(r)
) has been registered

execute plugin 'hertz' failed: exit status 4

make: *** [gen] Error 4

To Reproduce

Steps to reproduce the behavior:

  1. Create two different thrift files with namespaces similar to the previous ones.
  2. Use "hz update" on two files. such as hz update -idl ./idl/admin/technician.thrift

Expected behavior

If this check is blocked, it can actually generate b.register(r) and admin_b.register(r), without encountering any issues elsewhere.

Screenshots

If applicable, add screenshots to help explain your problem.

Hertz version:

0.7.1

Environment:

❯ go env                    
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/ozlinex/Library/Caches/go-build'
GOENV='/Users/ozlinex/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/ozlinex/go/pkg/mod'
GONOPROXY='github.com/west2-online'
GONOSUMDB='github.com/west2-online'
GOOS='darwin'
GOPATH='/Users/ozliinex/go'
GOPRIVATE='github.com/west2-online'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/opt/homebrew/Cellar/go/1.21.5/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.21.5/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.5'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/ozlinex/projects/repair/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/d4/t6l8w_nn5dd1b81nnyg629d40000gn/T/go-build3271880908=/tmp/go-build -gno-record-gcc-switches -fno-common
@li-jin-gou li-jin-gou added the bug Something isn't working label Dec 16, 2023
@FGYFFFF FGYFFFF added enhancement New feature or request and removed bug Something isn't working labels Dec 18, 2023
@FGYFFFF
Copy link
Contributor

FGYFFFF commented Dec 18, 2023

register 是按照 namespace 的分层来设计的,如果 namespace 最后一层相同的话,其包名也是一样的。这块工具不太好自动做区分,因为没有缓存,下次如果还有类似情况,可能导致一些复杂的 case 出现

@ozline
Copy link
Author

ozline commented Dec 18, 2023

register 是按照 namespace 的分层来设计的,如果 namespace 最后一层相同的话,其包名也是一样的。这块工具不太好自动做区分,因为没有缓存,下次如果还有类似情况,可能导致一些复杂的 case 出现

我目前的项目中,hz 会对同名包(比如 admin/xxx 和 xxx)做一些区分,前者会设置一个 admin_xxx 的别名

我将 hz 中的文本匹配强化为正则表达式后重新使用 hz update 没有遇见问题,更改 idl 后也可以正常识别并更新,其他目录也没有出现报错

如果需要详细的代码内容可以查看一下我的 pr (•̀ᴗ• ) ̑̑

@FGYFFFF
Copy link
Contributor

FGYFFFF commented Dec 18, 2023

@ozline ok,我一会看下。这块确实也可以优化下~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants