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

pull/2009/head
qi 3 years ago committed by GitHub
parent 5c66fcdc5a
commit 53c8877ce4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      cmd/protoc-gen-go-errors/template.go

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

Loading…
Cancel
Save