fix(protoc-gen-go-errors): fix generated function comments have extra blank lines. (#2008)

status-code-override
qi 3 years ago committed by chenzhihui
parent 3375816ce0
commit 8a8694c16c
  1. 4
      cmd/protoc-gen-go-errors/template.go

@ -8,7 +8,7 @@ import (
var errorsTemplate = ` var errorsTemplate = `
{{ range .Errors }} {{ range .Errors }}
{{if .HasComment}}{{.Comment}}{{end}} {{ if .HasComment }}{{ .Comment }}{{ end -}}
func Is{{.CamelValue}}(err error) bool { func Is{{.CamelValue}}(err error) bool {
if err == nil { if err == nil {
return false return false
@ -17,7 +17,7 @@ func Is{{.CamelValue}}(err error) bool {
return e.Reason == {{ .Name }}_{{ .Value }}.String() && e.Code == {{ .HTTPCode }} return e.Reason == {{ .Name }}_{{ .Value }}.String() && e.Code == {{ .HTTPCode }}
} }
{{if .HasComment}}{{.Comment}}{{end}} {{ if .HasComment }}{{ .Comment }}{{ end -}}
func Error{{ .CamelValue }}(format string, args ...interface{}) *errors.Error { func Error{{ .CamelValue }}(format string, args ...interface{}) *errors.Error {
return errors.New({{ .HTTPCode }}, {{ .Name }}_{{ .Value }}.String(), fmt.Sprintf(format, args...)) return errors.New({{ .HTTPCode }}, {{ .Name }}_{{ .Value }}.String(), fmt.Sprintf(format, args...))
} }

Loading…
Cancel
Save