From 3806fb93365c8bd44286ee4754502098d91d4b39 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 d63b267..9a7094a 100644 --- a/util.go +++ b/util.go @@ -1002,6 +1002,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)")