Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ReplaceAll instead of Replace with -1 pos #3003

Merged
merged 1 commit into from Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions protoc-gen-grpc-gateway/internal/gengateway/template.go
Expand Up @@ -253,12 +253,12 @@ var _ = metadata.Join
{{end}}
`))

_ = template.Must(handlerTemplate.New("request-func-signature").Parse(strings.Replace(`
_ = template.Must(handlerTemplate.New("request-func-signature").Parse(strings.ReplaceAll(`
{{if .Method.GetServerStreaming}}
func request_{{.Method.Service.GetName}}_{{.Method.GetName}}_{{.Index}}(ctx context.Context, marshaler runtime.Marshaler, client {{.Method.Service.InstanceName}}Client, req *http.Request, pathParams map[string]string) ({{.Method.Service.InstanceName}}_{{.Method.GetName}}Client, runtime.ServerMetadata, error)
{{else}}
func request_{{.Method.Service.GetName}}_{{.Method.GetName}}_{{.Index}}(ctx context.Context, marshaler runtime.Marshaler, client {{.Method.Service.InstanceName}}Client, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error)
{{end}}`, "\n", "", -1)))
{{end}}`, "\n", "")))

_ = template.Must(handlerTemplate.New("client-streaming-request-func").Parse(`
{{template "request-func-signature" .}} {
Expand Down Expand Up @@ -480,11 +480,11 @@ var (
{{end}}
`))

_ = template.Must(localHandlerTemplate.New("local-request-func-signature").Parse(strings.Replace(`
_ = template.Must(localHandlerTemplate.New("local-request-func-signature").Parse(strings.ReplaceAll(`
{{if .Method.GetServerStreaming}}
{{else}}
func local_request_{{.Method.Service.GetName}}_{{.Method.GetName}}_{{.Index}}(ctx context.Context, marshaler runtime.Marshaler, server {{.Method.Service.InstanceName}}Server, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error)
{{end}}`, "\n", "", -1)))
{{end}}`, "\n", "")))

_ = template.Must(localHandlerTemplate.New("local-client-rpc-request-func").Funcs(funcMap).Parse(`
{{$AllowPatchFeature := .AllowPatchFeature}}
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-openapiv2/internal/genopenapi/template.go
Expand Up @@ -2231,7 +2231,7 @@ func goTemplateComments(comment string, data interface{}, reg *descriptor.Regist
},
// Grabs title and description from a field
"fieldcomments": func(msg *descriptor.Message, field *descriptor.Field) string {
return strings.Replace(fieldProtoComments(reg, msg, field), "\n", "<br>", -1)
return strings.ReplaceAll(fieldProtoComments(reg, msg, field), "\n", "<br>")
},
}).Parse(comment)
if err != nil {
Expand Down