From 5565534f7936cc2176969dd5accf68837a212750 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 18 Oct 2023 00:37:00 +0300 Subject: [PATCH] check error field in proto message Signed-off-by: Vasiliy Tolstov --- util.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util.go b/util.go index a2e912e..a684bd2 100644 --- a/util.go +++ b/util.go @@ -1009,6 +1009,11 @@ func (g *Generator) writeErrors(plugin *protogen.Plugin) error { return err } + for _, field := range msg.Fields { + if field.GoName == "Error" { + return fmt.Errorf("failed generate Error() string interface for %s message %s already have Error field", field.Location.SourceFile, msg.Desc.Name()) + } + } gfile.P(`func (m *`, msg.GoIdent.GoName, `) Error() string {`) gfile.P(`buf, _ := marshaler.Marshal(m)`) gfile.P("return string(buf)")