zeromicro / go-zero

A cloud-native Go microservices framework with cli tool for productivity.
https://go-zero.dev
MIT License
29.15k stars 3.94k forks source link

文档中有一处问题,内附解决方法 #1259

Closed EthanChenLi closed 2 years ago

EthanChenLi commented 2 years ago

系统环境 : windows 10 x64 golang version : 1.17.0 goctl version: 1.2.3 windows/amd64 文档错误url: https://go-zero.dev/cn/micro-service.html https://go-zero.dev/cn/goctl-rpc.html

按文档的方式生成user.proto文件,然后使用goctl rpc proto -src user.proto -dir .命令生成桩代码会出现如下错误:

protoc  --proto_path=E:\go_work\src\go-zero\mall\user\rpc user.proto --go_out=plugins=grpc:E:\go_work\src\go-zero\mall\user\rpc\user --go_opt=Muser.proto=.
goctl: generation error: protoc-gen-go: invalid Go import path "." for "user.proto"

The import path must contain at least one forward slash ('/') character.

See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.

--go_out: protoc-gen-go: Plugin failed with status code 1.
goctl version: 1.2.3 windows/amd64

解决办法:
将proto文件中的

option go_package="user";

修改为

option go_package="./user";
kesonan commented 2 years ago

这不是 bug 哈,这是 proto 的基本使用了. 你的 protoc-gen-go版本不同,其要求 proto 写法也有差异,文档里不会对 proto 做过多介绍

kevwan commented 2 years ago

依赖protoc-gen-go版本,closing.