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