简体   繁体   English

当我们使用Google协议缓冲区时,可以修改生成的pb.go文件吗?

[英]When we use the google protocol buffer, could we modify the generated pb.go file?

For example, is it ok to add an interface or associate a function I created with a struct in the generated pb.go file? 例如,可以在生成的pb.go文件中添加接口或将我创建的函数与结构相关联吗?

The reason that I want to make these kinds of changes is it would make my code easier to implement. 我要进行此类更改的原因是它将使我的代码更易于实现。 I am not sure if I am allowed to do this since the first commented line in the generated file says "DO NOT EDIT". 我不确定是否可以执行此操作,因为生成的文件中第一条注释行显示“请勿编辑”。

You can edit generated code as much as you want. 您可以随意编辑生成的代码。 But It's not recommended because if you compile the code again your changes will be discarded and maybe you face some unexpected bugs. 但是不建议这样做,因为如果再次编译代码,所做的更改将被放弃,并且可能会遇到一些意外的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM