登录
首页 >  Golang >  Go问答

生成file.go的方法使用protoc(GRPC)是什么?

来源:stackoverflow

时间:2024-03-03 08:57:20 434浏览 收藏

你在学习Golang相关的知识吗?本文《生成file.go的方法使用protoc(GRPC)是什么?》,主要介绍的内容就涉及到,如果你想提升自己的开发能力,就不要错过这篇文章,大家要知道编程理论基础和实战操作都是不可或缺的哦!

问题内容

我在 calc 文件夹中有calculator.proto,如下所示:

syntax = "proto3";

package calc;

option go_package = "learn_grpc_datnd";

service calculatorservice {
    
}

当我运行 protoc --go-gprc_out=.; 时calc/calculator.proto 显示错误

Missing input file.
calc/calculator.proto: line 1: syntax: command not found
calc/calculator.proto: line 3: package: command not found
calc/calculator.proto: line 5: option: command not found
CalculatorService: unrecognized service
calc/calculator.proto: line 9: syntax error near unexpected token `}'
calc/calculator.proto: line 9: `} '
为什么?我已经安装了所有必需的软件包。

正确答案


您需要在原型中进行以下更改

option go_package = "./learn_grpc_datnd";

然后使用此命令生成文件。

protoc --go_out=paths=source_relative:./ --go-grpc_out=paths=source_relative:./ file.proto

到这里,我们也就讲完了《生成file.go的方法使用protoc(GRPC)是什么?》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于的知识点!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>