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

编译cmd的时候报错“..\internal\service\service.go:34:54: undefined: api.HelloReq” #41

Closed
xiaohei2015 opened this issue Apr 25, 2019 · 5 comments · Fixed by #51
Labels
help wanted Extra attention is needed

Comments

@xiaohei2015
Copy link

说明:进入cmd目录运行go build的时候,报了错误“..\internal\service\service.go:34:54: undefined: api.HelloReq”,对比官方给出的kratos-demo,发现api目录下面的文件api.pb.go并没有

重现步骤:

  1. go get -u github.com/bilibili/kratos/tool/kratos
  2. kratos init,按照命令要求,依次输入项目名称,负责人,并选择有gRPC的,当前目录生成
  3. 进入cmd目录执行go build

环境:

  1. Win7+64位
  2. Go1.12.4
@lealife
Copy link

lealife commented Apr 25, 2019

别着急, 文档还没写清楚, 要先用工具生成api.pb.go.
我在等文档都写好了再用它.

如果你真要使用rpc功能, 看看 https://github.com/bilibili/kratos/blob/master/doc/wiki-cn/warden-quickstart.md 这个文档, 但你会发现在 kratos tool kprotoc这个命令无效, 因为 kprotoc还没安装, 关键是没有文档写怎么安装 kprotoc, 我来告诉你, kprotoc 这个东西在 https://github.com/bilibili/kratos/tree/master/tool/kprotoc, 你看看install_kprotoc.sh应该就清楚了.

当然, 可能还会有坑, 这个命令不支持多gopath的情况, 所以可能你还要改改.

就算你真的生成了api.pb.go, 成功运行后, 你会试着调用这个rpc, 当然, 这又是一个巨大的挑战, 因为还有discovery的坑等着你...

这是一个文档还没写明白就着急开源的项目, 对前期的试用者是一个巨大的挑战, 当然也会让潜在的爱好者放弃.

@Terry-Mao Terry-Mao added the help wanted Extra attention is needed label Apr 25, 2019
@Terry-Mao
Copy link
Member

@lealife 可以先关注,我们逐渐再完善中,也谢谢反馈。其实我们并不是强依赖discovery,naming是一个抽象,可以实现zk、etcd等,但是时间原因都还没来得及实现,也欢迎贡献PR

@lealife
Copy link

lealife commented Apr 25, 2019

期待尽快完善!! 持续关注.

@fl260919784
Copy link

一键默认生成没有这个问题,自定义生成确实复现这个问题

@felixhao
Copy link
Collaborator

GOOS

  • macos: shoult always be successful, if not install protoc and gogo protobuf, then run:
    • cd kratos-demo/api
    • kratos tool kprotoc
    • cd kratos-demo/cmd & go build
  • windows: install protoc and gogo protobuf,then run:
    • cd kratos-demo/api
    • protoc --gogofast_out=plugins=grpc:$GOPATH/src api.proto
    • cd kratos-demo/cmd & go build
  • linux: install protoc first, then run:
    • cd kratos-demo/api
    • kratos tool kprotoc
    • cd kratos-demo/cmd & go build

protoc:https://github.com/protocolbuffers/protobuf#protocol-compiler-installation
gogo protobuf:https://github.com/gogo/protobuf
kratos tool:https://github.com/bilibili/kratos/blob/master/doc/wiki-cn/kratos-tool.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants