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

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

问题描述:

For example, is it ok to add an interface or associate a function I created with a struct in the generated pb.go file?

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".

例如,可以在生成的pb中添加接口或将我创建的函数与结构相关联吗? p>

我要进行此类更改的原因是它将使我的代码更易于实现。 我不确定是否可以执行此操作,因为生成的文件中第一条注释行显示“请勿编辑”。 p> div>

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.